Browse Source

Merging in latest from upstream (BA/design:refs/heads/dev)

* commit '6f14124119d627cdaa8cf7b49a60fde878f8bd4a': (85 commits)
  无jira任务 应用补丁的时候有一个没有删除
  移到designer_base
  pmd
  REPORT-2213 设计器右上角使用qq登录后,登录界面关不掉 & 这部分的代码质量
  REPORT-2335 插件管理界面以及右上角的登录界面,多次点击后,页面无法关闭
  无JIRA任务  合并代码时的错误覆盖
  REPORT-1885 frm跑马灯=>默认字体由textPane确定,不写死
  无任务,pmd
  REPORT-2537 多层次部门工具栏权限细粒度设置不生效
  REPORT-2483 国际化key转移;去掉空白行
  无任务,冲突调整,release到dev
  无JIRA任务,国际化,把release、master中的key合并到dev中
  无JIRA任务,解决冲突
  ct
  ct
  ct
  ct
  1
  ct
  REPORT-2526 tab交互改良后续--tab页签调整的视觉调整
  ...
master
Mango 7 years ago
parent
commit
e23eaf5d4d
  1. 1
      .gitignore
  2. 2
      designer/src/com/fr/design/cell/editor/RichTextToolBar.java
  3. 252
      designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java
  4. 830
      designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java
  5. 9
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  6. 4
      designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  7. 16
      designer/src/com/fr/design/widget/CellWidgetCardPane.java
  8. 345
      designer_base/src/com/fr/design/actions/server/ConnectionListAction.java
  9. 4
      designer_base/src/com/fr/design/actions/server/PluginManagerAction.java
  10. 55
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  11. 45
      designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java
  12. 266
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  13. 324
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java
  14. 155
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java
  15. 15
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionShowPane.java
  16. 19
      designer_base/src/com/fr/design/extra/LoginDialog.java
  17. 152
      designer_base/src/com/fr/design/extra/LoginPane.java
  18. 151
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  19. 14
      designer_base/src/com/fr/design/extra/LoginWebPane.java
  20. 10
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  21. 4
      designer_base/src/com/fr/design/extra/QQLoginDialog.java
  22. 145
      designer_base/src/com/fr/design/extra/QQLoginPane.java
  23. 131
      designer_base/src/com/fr/design/extra/QQLoginWebBridge.java
  24. 129
      designer_base/src/com/fr/design/extra/QQLoginWebPane.java
  25. 36
      designer_base/src/com/fr/design/extra/ReuseWebBridge.java
  26. 54
      designer_base/src/com/fr/design/extra/ReuseWebPane.java
  27. 58
      designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
  28. 13
      designer_base/src/com/fr/design/formula/VariableResolverAdapter.java
  29. 52
      designer_base/src/com/fr/design/gui/style/BorderPane.java
  30. BIN
      designer_base/src/com/fr/design/images/control/tab/end.png
  31. BIN
      designer_base/src/com/fr/design/images/control/tab/end_not.png
  32. BIN
      designer_base/src/com/fr/design/images/control/tab/first.png
  33. BIN
      designer_base/src/com/fr/design/images/control/tab/first_not.png
  34. BIN
      designer_base/src/com/fr/design/images/control/tab/next.png
  35. BIN
      designer_base/src/com/fr/design/images/control/tab/next_not.png
  36. BIN
      designer_base/src/com/fr/design/images/control/tab/prev.png
  37. BIN
      designer_base/src/com/fr/design/images/control/tab/prev_not.png
  38. 1409
      designer_base/src/com/fr/design/locale/designer.properties
  39. 1410
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  40. 1428
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  41. 1432
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  42. 1405
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  43. 1417
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  44. 7
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  45. 15
      designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
  46. 356
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  47. 190
      designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java
  48. 243
      designer_base/src/com/fr/design/style/color/ColorSelectPane.java
  49. 386
      designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
  50. 91
      designer_base/src/com/fr/design/style/color/RecentUseColorPane.java
  51. 219
      designer_base/src/com/fr/design/style/color/UsedColorPane.java
  52. 4
      designer_base/src/com/fr/start/BaseDesigner.java
  53. 2
      designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkPane.java
  54. 29
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/TableDataPane.java
  55. 79
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  56. 81
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  57. 217
      designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
  58. 59
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  59. 152
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  60. 924
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  61. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java
  62. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java
  63. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java
  64. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java
  65. 10
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  66. 17
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  67. 1
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  68. 55
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java
  69. 7
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java
  70. 7
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

1
.gitignore vendored

@ -3,5 +3,6 @@ designer_base/bin
designer_chart/bin designer_chart/bin
designer_form/bin designer_form/bin
*.iml *.iml
designer_base/src/com/fr/design/locale/.idea

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);

252
designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java

File diff suppressed because one or more lines are too long

830
designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.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;
@ -103,17 +102,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) {

16
designer/src/com/fr/design/widget/CellWidgetCardPane.java

@ -67,7 +67,12 @@ public class CellWidgetCardPane extends BasicPane {
treeTabPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); treeTabPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
widgetPropertyPane = new BasicWidgetPropertySettingPane(); widgetPropertyPane = new BasicWidgetPropertySettingPane();
attriTabPane.add(widgetPropertyPane, BorderLayout.NORTH); JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
northPane.setBorder(BorderFactory.createEmptyBorder(5, 8, 0, 8));
JPanel basic = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Form_Basic_Properties"));
northPane.add(basic);
basic.add(widgetPropertyPane);
attriTabPane.add(northPane, BorderLayout.NORTH);
attriCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); attriCardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
attriTabPane.add(attriCardPane, BorderLayout.CENTER); attriTabPane.add(attriCardPane, BorderLayout.CENTER);
attriCardLayout = (CardLayout) attriCardPane.getLayout(); attriCardLayout = (CardLayout) attriCardPane.getLayout();
@ -88,15 +93,6 @@ public class CellWidgetCardPane extends BasicPane {
this.tabbedPane.setEnabled(true); this.tabbedPane.setEnabled(true);
} }
attriTabPane.remove(widgetPropertyPane);
widgetPropertyPane = new BasicWidgetPropertySettingPane();
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
northPane.setBorder(BorderFactory.createEmptyBorder(5, 8, 0, 8));
JPanel basic = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Form_Basic_Properties"));
northPane.add(basic);
basic.add(widgetPropertyPane);
attriTabPane.add(northPane, BorderLayout.NORTH);
WidgetDefinePaneFactory.RN rn = WidgetDefinePaneFactory.createWidgetDefinePane(cellWidget, new Operator() { WidgetDefinePaneFactory.RN rn = WidgetDefinePaneFactory.createWidgetDefinePane(cellWidget, new Operator() {
@Override @Override
public void did(DataCreatorUI ui, String cardName) { public void did(DataCreatorUI ui, String cardName) {

345
designer_base/src/com/fr/design/actions/server/ConnectionListAction.java

@ -1,171 +1,176 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.ModifiedTable; import com.fr.base.ModifiedTable;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.connect.ConnectionManagerPane; import com.fr.design.data.datapane.connect.ConnectionManagerPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.data.datapane.connect.ConnectionShowPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet; import com.fr.design.mainframe.DesignerFrame;
import com.fr.file.DatasourceManager; import com.fr.design.menu.MenuKeySet;
import com.fr.file.DatasourceManagerProvider; import com.fr.file.DatasourceManager;
import com.fr.general.Inter; import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent; import javax.swing.*;
import java.util.HashMap; import java.awt.event.ActionEvent;
import java.util.HashMap;
/**
* DatasourceList Action /**
*/ * DatasourceList Action
public class ConnectionListAction extends UpdateAction { */
private static final int BYTENUM = 1444; public class ConnectionListAction extends UpdateAction {
public ConnectionListAction() { public ConnectionListAction() {
this.setMenuKeySet(DEFINE_DATA_CONNECTION); this.setMenuKeySet(DEFINE_DATA_CONNECTION);
this.setName(getMenuKeySet().getMenuKeySetName()); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_web/connection.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_web/connection.png"));
} }
public static final MenuKeySet DEFINE_DATA_CONNECTION = new MenuKeySet() { public static final MenuKeySet DEFINE_DATA_CONNECTION = new MenuKeySet() {
@Override @Override
public char getMnemonic() { public char getMnemonic() {
return 'D'; return 'D';
} }
@Override @Override
public String getMenuName() { public String getMenuName() {
return Inter.getLocText("Server-Define_Data_Connection"); return Inter.getLocText("Server-Define_Data_Connection");
} }
@Override @Override
public KeyStroke getKeyStroke() { public KeyStroke getKeyStroke() {
return null; return null;
} }
}; };
/** /**
* 执行动作 * 执行动作
* *
* @param evt 事件 * @param evt 事件
*/ */
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance(); final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
final DatasourceManager backupManager = datasourceManager.getBackUpManager(); final DatasourceManager backupManager = datasourceManager.getBackUpManager();
final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() {
public void complete() { public void complete() {
populate(datasourceManager); populate(datasourceManager);
} }
protected void renameConnection(String oldName, String newName) { protected void renameConnection(String oldName, String newName) {
datasourceManager.getConnectionLocalModifyTable().rename(oldName, newName); datasourceManager.getConnectionLocalModifyTable().rename(oldName, newName);
} }
}; };
final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null);
databaseListDialog.addDialogActionListener(new DialogActionAdapter() { databaseListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
if (!databaseManagerPane.isNamePermitted()) { if (!databaseManagerPane.isNamePermitted()) {
databaseListDialog.setDoOKSucceed(false); databaseListDialog.setDoOKSucceed(false);
return; return;
} }
if (!doWithDatasourceManager(datasourceManager, backupManager, databaseManagerPane, databaseListDialog)) { if (!doWithDatasourceManager(datasourceManager, backupManager, databaseManagerPane, databaseListDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return; return;
} }
// marks:保存数据 // marks:保存数据
writeFile(datasourceManager); writeFile(datasourceManager);
} }
public void doCancel() { public void doCancel() {
datasourceManager.synchronizedWithServer(); datasourceManager.synchronizedWithServer();
} }
}); });
databaseListDialog.setVisible(true); databaseListDialog.setVisible(true);
} }
private void writeFile(DatasourceManagerProvider datasourceManager) { /**
Env currentEnv = FRContext.getCurrentEnv(); * @param datasourceManager
try { */
boolean isSuccess = currentEnv.writeResource(datasourceManager); public static void writeFile(DatasourceManagerProvider datasourceManager) {
if (!isSuccess) { Env currentEnv = FRContext.getCurrentEnv();
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist")); try {
} boolean isSuccess = currentEnv.writeResource(datasourceManager);
} catch (Exception e) { if (!isSuccess) {
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist")); throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist"));
} }
DesignerContext.getDesignerBean("databasename").refreshBeanElement(); } catch (Exception e) {
} throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist"));
}
/** DesignerContext.getDesignerBean("databasename").refreshBeanElement();
* 是否正常更新完datasourceManager }
*
* @param datasourceManager /**
* @param databaseManagerPane * 更新datasourceManager
* @return *
*/ * @param datasourceManager datasource管理对象
private boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager backupManager, * @param backupManager datasource管理对象备份
ConnectionManagerPane databaseManagerPane, BasicDialog databaseListDialog) { * @param connectionShowPane datasource面板
databaseManagerPane.update(datasourceManager); * @param databaseListDialog datasource管理对话框
HashMap<String, Connection> modifyDetails = datasourceManager.getConnectionModifyDetails(); * @return boolean 是否更新成功
modifyDetails.clear(); */
Env currentEnv = FRContext.getCurrentEnv(); public static boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager
ModifiedTable localModifiedTable = datasourceManager.checkConnectionModifyTable(backupManager, currentEnv.getUserID()); backupManager, ConnectionShowPane connectionShowPane, BasicDialog databaseListDialog) {
boolean isFailed = false; connectionShowPane.update(datasourceManager);
if (currentEnv.isSupportLocalFileOperate() && !((LocalEnv) currentEnv).isNoRemoteUser()) { HashMap<String, Connection> modifyDetails = datasourceManager.getConnectionModifyDetails();
//如果是本地,并且有远程用户时则更新自己的修改表 modifyDetails.clear();
datasourceManager.updateSelfConnectionTotalModifiedTable(localModifiedTable, ModifiedTable.LOCAL_MODIFIER); Env currentEnv = FRContext.getCurrentEnv();
} else { ModifiedTable localModifiedTable = datasourceManager.checkConnectionModifyTable(backupManager, currentEnv.getUserID());
if (!currentEnv.isSupportLocalFileOperate()) { boolean isFailed = false;
//如果是远程,则去取服务器的最新的修改表,检查有没有冲突 if (currentEnv.isSupportLocalFileOperate() && !((LocalEnv) currentEnv).isNoRemoteUser()) {
ModifiedTable currentServerModifyTable = currentEnv.getDataSourceModifiedTables(DatasourceManager.CONNECTION); //如果是本地,并且有远程用户时则更新自己的修改表
if (localModifiedTable.checkModifiedTableConflictWithServer(currentServerModifyTable, currentEnv.getUserID())) { datasourceManager.updateSelfConnectionTotalModifiedTable(localModifiedTable, ModifiedTable.LOCAL_MODIFIER);
//有冲突,进行提示 } else {
String title = Inter.getLocText(new String[]{"Select", "Single", "Setting"}); if (!currentEnv.isSupportLocalFileOperate()) {
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), localModifiedTable.getWaringMessage(), title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); //如果是远程,则去取服务器的最新的修改表,检查有没有冲突
if (returnVal == JOptionPane.YES_OPTION) { ModifiedTable currentServerModifyTable = currentEnv.getDataSourceModifiedTables(DatasourceManager.CONNECTION);
//点击是,进行相应刷新去冲突 if (localModifiedTable.checkModifiedTableConflictWithServer(currentServerModifyTable, currentEnv.getUserID())) {
datasourceManager.synchronizedWithServer(backupManager, DatasourceManager.CONNECTION); //有冲突,进行提示
//要是有重命名冲突的,则对详细的修改表先进行修改 String title = Inter.getLocText(new String[]{"Select", "Single", "Setting"});
datasourceManager.doWithConnectionConflict(localModifiedTable); int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), localModifiedTable.getWaringMessage(), title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
localModifiedTable.removeConfilct(); if (returnVal == JOptionPane.YES_OPTION) {
modifyDetails.clear(); //点击是,进行相应刷新去冲突
//更新面板 datasourceManager.synchronizedWithServer(backupManager, DatasourceManager.CONNECTION);
databaseManagerPane.populate(datasourceManager); //要是有重命名冲突的,则对详细的修改表先进行修改
} else { datasourceManager.doWithConnectionConflict(localModifiedTable);
//更新失败,继续停留页面 localModifiedTable.removeConfilct();
isFailed = true; modifyDetails.clear();
} //更新面板
connectionShowPane.populate(datasourceManager);
} } else {
} //更新失败,继续停留页面
} isFailed = true;
//存在请重命名则不能更新 }
int index = datasourceManager.isConnectionMapContainsRename();
if (index != -1) { }
isFailed = true; }
databaseManagerPane.setSelectedIndex(index); }
} //存在请重命名则不能更新
databaseListDialog.setDoOKSucceed(!isFailed); int index = datasourceManager.isConnectionMapContainsRename();
//如果修改成功,则去远程端增量修改修改表 if (index != -1) {
if (!isFailed && !currentEnv.isSupportLocalFileOperate()) { isFailed = true;
currentEnv.writeDataSourceModifiedTables(localModifiedTable, DatasourceManager.CONNECTION); connectionShowPane.setSelectedIndex(index);
localModifiedTable.clear(); }
modifyDetails.clear(); databaseListDialog.setDoOKSucceed(!isFailed);
} //如果修改成功,则去远程端增量修改修改表
return !isFailed; if (!isFailed && !currentEnv.isSupportLocalFileOperate()) {
} currentEnv.writeDataSourceModifiedTables(localModifiedTable, DatasourceManager.CONNECTION);
localModifiedTable.clear();
modifyDetails.clear();
public void update() { }
this.setEnabled(true); return !isFailed;
} }
public void update() {
this.setEnabled(true);
}
} }

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() {

55
designer_base/src/com/fr/design/beans/location/MoveUtils.java

@ -18,9 +18,7 @@ public class MoveUtils {
public static final int SORPTION_UNIT = 5; public static final int SORPTION_UNIT = 5;
private static final int EQUIDISTANTLINE_UNIT = 4; private static final int EQUIDISTANTLINE_UNIT = 4;
public static WidgetForbidWindow widgetForbidWindow = new WidgetForbidWindow(); private static ArrayList<EquidistantLine> equidistantLines = new ArrayList<>();
public static ArrayList<EquidistantLine> equidistantLines = new ArrayList<>();
private MoveUtils() { private MoveUtils() {
@ -259,8 +257,7 @@ public class MoveUtils {
equidistantLineInfo.setReference(bounds.y); equidistantLineInfo.setReference(bounds.y);
equidistantLineInfo.setDirection(SwingConstants.BOTTOM); equidistantLineInfo.setDirection(SwingConstants.BOTTOM);
} }
} } else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))) {
else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))){
//当前操作rec在bounds的右侧 //当前操作rec在bounds的右侧
if (left > (bounds.getX() + bounds.getWidth())){ if (left > (bounds.getX() + bounds.getWidth())){
equidistantLineInfo.setDistance(left - (bounds.x + bounds.width)); equidistantLineInfo.setDistance(left - (bounds.x + bounds.width));
@ -279,13 +276,6 @@ public class MoveUtils {
} }
} }
public static void displayForbidWindow(int x, int y) {
widgetForbidWindow.showWindow(x, y);
}
public static void hideForbidWindow() {
widgetForbidWindow.hideWindow();
}
/** /**
* 吸附 * 吸附
@ -318,25 +308,16 @@ public class MoveUtils {
RectangleIterator iterator = designer.createRectangleIterator(); RectangleIterator iterator = designer.createRectangleIterator();
java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>(); java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>();
//是否存在控件重叠 while (iterator.hasNext()) {
boolean isWidgetsIntersects = false; Rectangle bounds = iterator.nextRectangle();
while (iterator.hasNext()) { cacheRecs.add(bounds);
Rectangle bounds = iterator.nextRectangle(); findX(px, bounds, left, right, width);
cacheRecs.add(bounds); findY(py, bounds, top, bottom, height);
boolean isIntersects = operatingRectangle.intersects(bounds);
findX(px, bounds, left, right, width); if (!isParameterLayout) {
findY(py, bounds, top, bottom, height); findEquidistantLine(bounds, left, top, height, width);
}
if(!isParameterLayout){ }
if(isIntersects) {
isWidgetsIntersects = true;
}
else{
findEquidistantLine(bounds, left, top, height, width);
}
}
}
showForbiddenWindow(designer, x, y, isWidgetsIntersects);
createXAbsorptionline(px, designer, width, cacheRecs); createXAbsorptionline(px, designer, width, cacheRecs);
createYAbsorptionline(py, designer, height, cacheRecs); createYAbsorptionline(py, designer, height, cacheRecs);
@ -353,18 +334,6 @@ public class MoveUtils {
return sorptionPoint; return sorptionPoint;
} }
public static void showForbiddenWindow(RectangleDesigner designer, int x, int y, boolean isIntersects){
if (isIntersects){
if(designer.getDesignerLocationOnScreen() != null) {
displayForbidWindow(x + designer.getDesignerLocationOnScreen().x, y + designer.getDesignerLocationOnScreen().y);
}
designer.setWidgetsIntersected(true);
}
else{
designer.setWidgetsIntersected(false);
hideForbidWindow();
}
}
private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) { private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) {
Absorptionline line = null; Absorptionline line = null;

45
designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java

@ -1,45 +0,0 @@
package com.fr.design.beans.location;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.Inter;
import javax.swing.*;
/**
* Created by zhouping on 2016/7/24.
*/
public class WidgetForbidWindow extends JWindow {
private static final int WIDTH = 150;
private static final int HEIGHT = 20;
private UIButton promptButton = new UIButton(Inter.getLocText("FR-Designer_Forbid_Widgets_Intersects"), BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
/**
* 构造函数
*/
public WidgetForbidWindow() {
this.add(promptButton);
this.setSize(WIDTH, HEIGHT);
}
/**
* 在指定位置显示窗口, 默认将window的中心点放到指定位置上
*
* @param x x坐标
* @param y y坐标
*/
public void showWindow(int x, int y) {
this.setLocation(x - WIDTH / 2, y - HEIGHT / 2);
this.setVisible(true);
}
/**
* 隐藏当前窗口
*/
public void hideWindow() {
this.setVisible(false);
}
}

266
designer_base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -1,128 +1,140 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.Env; import com.fr.base.FRContext;
import com.fr.base.FRContext; import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.AbstractDatabaseConnection; import com.fr.data.impl.Connection;
import com.fr.data.impl.Connection; import com.fr.data.impl.NameDatabaseConnection;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.design.DesignerEnvManager;
import com.fr.design.DesignerEnvManager; import com.fr.design.actions.server.ConnectionListAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager; import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider; import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Iterator;
import java.util.List;
/**
* 选择数据连接的下拉框 /**
* * 选择数据连接的下拉框
* @editor zhou *
* @since 2012-3-28下午3:02:30 * @editor zhou
*/ * @since 2012-3-28下午3:02:30
public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { */
/** public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
* /**
*/ *
private static final long serialVersionUID = 1L; */
private Class<? extends Connection> cls; // 所取的Connection都是cls及其子类 private static final long serialVersionUID = 1L;
private java.util.List<String> nameList = new ArrayList<String>(); private Class<? extends Connection> cls; // 所取的Connection都是cls及其子类
private List<String> nameList = new ArrayList<String>();
public ConnectionComboBoxPanel(Class<? extends Connection> cls) {
super(); public ConnectionComboBoxPanel(Class<? extends Connection> cls) {
super();
this.cls = cls;
this.cls = cls;
// alex:添加item change监听,当改变时改变DesignerEnvManager中的最近选中的数据连接
this.itemComboBox.addItemListener(new ItemListener() { // alex:添加item change监听,当改变时改变DesignerEnvManager中的最近选中的数据连接
public void itemStateChanged(ItemEvent e) { this.itemComboBox.addItemListener(new ItemListener() {
String selected = ConnectionComboBoxPanel.this.getSelectedItem(); public void itemStateChanged(ItemEvent e) {
if (StringUtils.isNotBlank(selected)) { String selected = ConnectionComboBoxPanel.this.getSelectedItem();
DesignerEnvManager.getEnvManager().setRecentSelectedConnection(selected); if (StringUtils.isNotBlank(selected)) {
} DesignerEnvManager.getEnvManager().setRecentSelectedConnection(selected);
} }
}); }
refreshItems(); });
} refreshItems();
}
/*
* 刷新ComboBox.items /*
*/ * 刷新ComboBox.items
protected java.util.Iterator<String> items() { */
nameList = new ArrayList<String>(); protected Iterator<String> items() {
nameList = new ArrayList<String>();
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
java.util.Iterator<String> nameIt = mgr.getConnectionNameIterator(); DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
while (nameIt.hasNext()) { Iterator<String> nameIt = mgr.getConnectionNameIterator();
String conName = nameIt.next(); while (nameIt.hasNext()) {
Connection connection = mgr.getConnection(conName); String conName = nameIt.next();
filterConnection(connection, conName, nameList); Connection connection = mgr.getConnection(conName);
} filterConnection(connection, conName, nameList);
}
return nameList.iterator();
} return nameList.iterator();
}
protected void filterConnection(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class}); protected void filterConnection(Connection connection, String conName, List<String> nameList) {
} connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
}
public int getConnectionSize() { public int getConnectionSize() {
return nameList.size(); return nameList.size();
} }
public String getConnection(int i) { public String getConnection(int i) {
return nameList.get(i); return nameList.get(i);
} }
/* /*
* 弹出对话框编辑Items * 弹出对话框编辑Items
*/ */
protected void editItems() { protected void editItems() {
final ConnectionListPane connectionListPane = new ConnectionListPane(); final ConnectionListPane connectionListPane = new ConnectionListPane();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance(); final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
connectionListPane.populate(datasourceManager); final DatasourceManager backupManager = datasourceManager.getBackUpManager();
BasicDialog connectionListDialog = connectionListPane.showLargeWindow( connectionListPane.populate(datasourceManager);
SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), new DialogActionAdapter() { final BasicDialog connectionListDialog = connectionListPane.showLargeWindow(
public void doOk() { SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), null);
connectionListPane.update(datasourceManager); connectionListDialog.addDialogActionListener(new DialogActionAdapter() {
// marks:保存数据 public void doOk() {
Env currentEnv = FRContext.getCurrentEnv(); if (!connectionListPane.isNamePermitted()) {
try { connectionListDialog.setDoOKSucceed(false);
currentEnv.writeResource(datasourceManager); return;
} catch (Exception ex) { }
FRContext.getLogger().error(ex.getMessage(), ex); if (!ConnectionListAction.doWithDatasourceManager(datasourceManager, backupManager, connectionListPane,
} connectionListDialog)) {
} //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
}); return;
connectionListDialog.setVisible(true); }
refreshItems(); // marks:保存数据
} ConnectionListAction.writeFile(datasourceManager);
}
public void populate(com.fr.data.impl.Connection connection) {
editButton.setEnabled(FRContext.getCurrentEnv().isRoot()); public void doCancel() {
if (connection instanceof NameDatabaseConnection) { datasourceManager.synchronizedWithServer();
this.setSelectedItem(((NameDatabaseConnection) connection).getName()); }
} else { });
String s = DesignerEnvManager.getEnvManager().getRecentSelectedConnection(); connectionListDialog.setVisible(true);
if (StringUtils.isNotBlank(s)) { refreshItems();
for (int i = 0; i < this.getConnectionSize(); i++) { }
String t = this.getConnection(i);
if (ComparatorUtils.equals(s, t)) { /**
this.setSelectedItem(s); * @param connection 数据库链接
break; */
} public void populate(Connection connection) {
} editButton.setEnabled(FRContext.getCurrentEnv().isRoot());
} if (connection instanceof NameDatabaseConnection) {
// alex:如果这个ComboBox还是没有选中,那么选中第一个 this.setSelectedItem(((NameDatabaseConnection) connection).getName());
if (StringUtils.isBlank(this.getSelectedItem()) && this.getConnectionSize() > 0) { } else {
this.setSelectedItem(this.getConnection(0)); String s = DesignerEnvManager.getEnvManager().getRecentSelectedConnection();
} if (StringUtils.isNotBlank(s)) {
} for (int i = 0; i < this.getConnectionSize(); i++) {
} String t = this.getConnection(i);
if (ComparatorUtils.equals(s, t)) {
this.setSelectedItem(s);
break;
}
}
}
// alex:如果这个ComboBox还是没有选中,那么选中第一个
if (StringUtils.isBlank(this.getSelectedItem()) && this.getConnectionSize() > 0) {
this.setSelectedItem(this.getConnection(0));
}
}
}
} }

324
designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -1,163 +1,163 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ConnectionProvider; import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.file.DatasourceManagerProvider; import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.*;
import java.util.*; import java.util.*;
/** /**
* Connection List Pane. * Connection List Pane.
*/ */
public class ConnectionListPane extends JListControlPane { public class ConnectionListPane extends JListControlPane implements ConnectionShowPane {
public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection"); public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection");
private boolean isNamePermitted = true; private boolean isNamePermitted = true;
private HashMap<String, String> renameMap = new HashMap<String, String>(); private HashMap<String, String> renameMap = new HashMap<String, String>();
public ConnectionListPane() { public ConnectionListPane() {
renameMap.clear(); renameMap.clear();
this.addEditingListner(new PropertyChangeAdapter() { this.addEditingListner(new PropertyChangeAdapter() {
public void propertyChange() { public void propertyChange() {
isNamePermitted = true; isNamePermitted = true;
String[] allListNames = nameableList.getAllNames(); String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName(); String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) { if (StringUtils.isEmpty(tempName)) {
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"}; String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"};
String[] sign = new String[]{",", "!"}; String[] sign = new String[]{",", "!"};
nameableList.stopEditing(); nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), Inter.getLocText(warning, sign)); JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), Inter.getLocText(warning, sign));
setWarnigText(editingIndex); setWarnigText(editingIndex);
isNamePermitted = false; isNamePermitted = false;
return; return;
} }
if (!ComparatorUtils.equals(tempName, selectedName) if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeted(new List[]{Arrays.asList(allListNames)}, tempName)) { && isNameRepeted(new List[]{Arrays.asList(allListNames)}, tempName)) {
isNamePermitted = false; isNamePermitted = false;
nameableList.stopEditing(); nameableList.stopEditing();
String message = Inter.getLocText(new String[]{"Utils-has_been_existed", "DashBoard-ConnectionList", "Please_Rename"}, new String[]{"", tempName + ",", "!"}); String message = Inter.getLocText(new String[]{"Utils-has_been_existed", "DashBoard-ConnectionList", "Please_Rename"}, new String[]{"", tempName + ",", "!"});
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message); JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message);
setWarnigText(editingIndex); setWarnigText(editingIndex);
} }
if (isNamePermitted && !ComparatorUtils.equals(tempName, selectedName)) { if (isNamePermitted && !ComparatorUtils.equals(tempName, selectedName)) {
rename(selectedName, tempName); rename(selectedName, tempName);
} }
} }
}); });
} }
protected void rename(String oldName, String newName) { protected void rename(String oldName, String newName) {
if (renameMap.containsKey(selectedName)) { if (renameMap.containsKey(selectedName)) {
renameMap.remove(selectedName); renameMap.remove(selectedName);
} }
renameMap.put(selectedName, newName); renameMap.put(selectedName, newName);
} }
/** /**
* 名字是否允许 * 名字是否允许
* *
* @return / * @return /
*/ */
public boolean isNamePermitted() { public boolean isNamePermitted() {
return isNamePermitted; return isNamePermitted;
} }
/** /**
* 检查按钮可用状态 Check button enabled. * 检查按钮可用状态 Check button enabled.
*/ */
public void checkButtonEnabled() { public void checkButtonEnabled() {
super.checkButtonEnabled(); super.checkButtonEnabled();
isNamePermitted = !isContainsRename(); isNamePermitted = !isContainsRename();
} }
public HashMap<String, String> getRenameMap() { public HashMap<String, String> getRenameMap() {
return renameMap; return renameMap;
} }
/** /**
* 创建菜单项 * 创建菜单项
* *
* @return 菜单项 * @return 菜单项
*/ */
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
NameableCreator[] creators = new NameableCreator[]{new NameObjectCreator( NameableCreator[] creators = new NameableCreator[]{new NameObjectCreator(
"JDBC", "JDBC",
"/com/fr/design/images/data/source/jdbcTableData.png", "/com/fr/design/images/data/source/jdbcTableData.png",
JDBCDatabaseConnection.class, JDBCDatabaseConnection.class,
DatabaseConnectionPane.JDBC.class DatabaseConnectionPane.JDBC.class
), new NameObjectCreator( ), new NameObjectCreator(
"JNDI", "JNDI",
"/com/fr/design/images/data/source/jdbcTableData.png", "/com/fr/design/images/data/source/jdbcTableData.png",
JNDIDatabaseConnection.class, JNDIDatabaseConnection.class,
DatabaseConnectionPane.JNDI.class DatabaseConnectionPane.JNDI.class
)}; )};
Set<ConnectionProvider> pluginCreators = ExtraDesignClassManager.getInstance().getArray(ConnectionProvider.XML_TAG); Set<ConnectionProvider> pluginCreators = ExtraDesignClassManager.getInstance().getArray(ConnectionProvider.XML_TAG);
for (ConnectionProvider provider : pluginCreators) { for (ConnectionProvider provider : pluginCreators) {
NameObjectCreator creator = new NameObjectCreator( NameObjectCreator creator = new NameObjectCreator(
provider.nameForConnection(), provider.nameForConnection(),
provider.iconPathForConnection(), provider.iconPathForConnection(),
provider.classForConnection(), provider.classForConnection(),
provider.appearanceForConnection() provider.appearanceForConnection()
); );
creators = ArrayUtils.add(creators, creator); creators = ArrayUtils.add(creators, creator);
} }
return creators; return creators;
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return TITLE_NAME; return TITLE_NAME;
} }
/** /**
* Populate. * Populate.
* *
* @param datasourceManager the new datasourceManager. * @param datasourceManager the new datasourceManager.
*/ */
public void populate(DatasourceManagerProvider datasourceManager) { public void populate(DatasourceManagerProvider datasourceManager) {
Iterator<String> nameIt = datasourceManager.getConnectionNameIterator(); Iterator<String> nameIt = datasourceManager.getConnectionNameIterator();
List<NameObject> nameObjectList = new ArrayList<NameObject>(); List<NameObject> nameObjectList = new ArrayList<NameObject>();
while (nameIt.hasNext()) { while (nameIt.hasNext()) {
String name = nameIt.next(); String name = nameIt.next();
nameObjectList.add(new NameObject(name, datasourceManager.getConnection(name))); nameObjectList.add(new NameObject(name, datasourceManager.getConnection(name)));
} }
this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
} }
/** /**
* Update. * Update.
*/ */
public void update(DatasourceManagerProvider datasourceManager) { public void update(DatasourceManagerProvider datasourceManager) {
// Nameable[]居然不能强转成NameObject[],一定要这么写... // Nameable[]居然不能强转成NameObject[],一定要这么写...
Nameable[] res = this.update(); Nameable[] res = this.update();
NameObject[] res_array = new NameObject[res.length]; NameObject[] res_array = new NameObject[res.length];
java.util.Arrays.asList(res).toArray(res_array); java.util.Arrays.asList(res).toArray(res_array);
datasourceManager.clearAllConnection(); datasourceManager.clearAllConnection();
for (int i = 0; i < res_array.length; i++) { for (int i = 0; i < res_array.length; i++) {
NameObject nameObject = res_array[i]; NameObject nameObject = res_array[i];
datasourceManager.putConnection(nameObject.getName(), (Connection) nameObject.getObject()); datasourceManager.putConnection(nameObject.getName(), (Connection) nameObject.getObject());
} }
} }
} }

155
designer_base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java

@ -1,78 +1,79 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.file.DatasourceManagerProvider; import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
public class ConnectionManagerPane extends LoadingBasicPane { public class ConnectionManagerPane extends LoadingBasicPane implements ConnectionShowPane {
private UITextField connectionTextField; private UITextField connectionTextField;
private ConnectionListPane connectionListPane; private ConnectionListPane connectionListPane;
protected void initComponents(JPanel container) { protected void initComponents(JPanel container) {
container.setLayout(FRGUIPaneFactory.createBorderLayout()); container.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel connectionPathPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel connectionPathPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
container.add(connectionPathPane, BorderLayout.NORTH); container.add(connectionPathPane, BorderLayout.NORTH);
connectionPathPane.setBorder(BorderFactory.createEmptyBorder(6, 2, 2, 2)); connectionPathPane.setBorder(BorderFactory.createEmptyBorder(6, 2, 2, 2));
connectionPathPane.add(new UILabel(Inter.getLocText("FR-Designer_Save_Path") + ":"), BorderLayout.WEST); connectionPathPane.add(new UILabel(Inter.getLocText("FR-Designer_Save_Path") + ":"), BorderLayout.WEST);
this.connectionTextField = new UITextField(); this.connectionTextField = new UITextField();
connectionPathPane.add(connectionTextField, BorderLayout.CENTER); connectionPathPane.add(connectionTextField, BorderLayout.CENTER);
this.connectionTextField.setEditable(false); this.connectionTextField.setEditable(false);
connectionListPane = new ConnectionListPane(){ connectionListPane = new ConnectionListPane() {
protected void rename(String oldName,String newName) { protected void rename(String oldName, String newName) {
super.rename(oldName,newName); super.rename(oldName, newName);
renameConnection(oldName,newName); renameConnection(oldName, newName);
} }
}; };
container.add(connectionListPane, BorderLayout.CENTER); container.add(connectionListPane, BorderLayout.CENTER);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("Server-Define_Data_Connection"); return Inter.getLocText("Server-Define_Data_Connection");
} }
public HashMap<String, String> getRenameMap() { public HashMap<String, String> getRenameMap() {
return connectionListPane.getRenameMap(); return connectionListPane.getRenameMap();
} }
public void populate(DatasourceManagerProvider datasourceManager) { public void populate(DatasourceManagerProvider datasourceManager) {
this.connectionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME this.connectionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME
+ File.separator + datasourceManager.fileName()); + File.separator + datasourceManager.fileName());
this.connectionListPane.populate(datasourceManager); this.connectionListPane.populate(datasourceManager);
} }
public void update(DatasourceManagerProvider datasourceManager) { public void update(DatasourceManagerProvider datasourceManager) {
this.connectionListPane.update(datasourceManager); this.connectionListPane.update(datasourceManager);
} }
/** /**
* 设置选中项 * 设置选中项
* *
* @param index 选中项的序列号 * @param index 选中项的序列号
*/ */
public void setSelectedIndex(int index) { public void setSelectedIndex(int index) {
this.connectionListPane.setSelectedIndex(index); this.connectionListPane.setSelectedIndex(index);
} }
/** /**
* 名字是否允许 * 名字是否允许
* @return 允许返回true *
*/ * @return 允许返回true
public boolean isNamePermitted() { */
return connectionListPane.isNamePermitted(); public boolean isNamePermitted() {
} return connectionListPane.isNamePermitted();
}
} }

15
designer_base/src/com/fr/design/data/datapane/connect/ConnectionShowPane.java

@ -0,0 +1,15 @@
package com.fr.design.data.datapane.connect;
import com.fr.file.DatasourceManagerProvider;
/**
* Created by yaoh.wu on 2017/4/22.
* 数据链接显示面板
*/
public interface ConnectionShowPane {
void update(DatasourceManagerProvider datasourceManager);
void populate(DatasourceManagerProvider datasourceManager);
void setSelectedIndex(int index);
}

19
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);
setUndecorated(true); if (StableUtils.getMajorJavaVersion() == 8) {
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));
}
}

151
designer_base/src/com/fr/design/extra/LoginWebBridge.java

@ -6,7 +6,6 @@ import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.ucenter.Client; import com.fr.design.extra.ucenter.Client;
import com.fr.design.extra.ucenter.XMLHelper; import com.fr.design.extra.ucenter.XMLHelper;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -14,10 +13,10 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -47,50 +46,48 @@ public class LoginWebBridge {
//用户名,密码为空 //用户名,密码为空
private static final String LOGIN_INFO_EMPTY = "-5"; private static final String LOGIN_INFO_EMPTY = "-5";
private static final int TIME_OUT = 10000; private static final int TIME_OUT = 10000;
private static final String LOGIN_SUCCESS = "ok";
private static final String LOGIN_FAILED = "failed";
private static com.fr.design.extra.LoginWebBridge helper; private static LoginWebBridge helper;
private UILabel pluginuiLabel;
private UIDialog uiDialog; private UIDialog uiDialog;
private UIDialog qqDialog;
private UILabel uiLabel; private UILabel uiLabel;
private String userName; private String userName;
public int getMessageCount() { public LoginWebBridge() {
return messageCount; String username = DesignerEnvManager.getEnvManager().getBBSName();
} setUserName(username, uiLabel);
/**
* 测试论坛网络连接
* @return
*/
private boolean testConnection() {
HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test"));
return client.isServerAlive();
} }
public static com.fr.design.extra.LoginWebBridge getHelper() { public static LoginWebBridge getHelper() {
if (helper != null) { if (helper != null) {
return helper; return helper;
} }
synchronized (com.fr.design.extra.LoginWebBridge.class) { synchronized (LoginWebBridge.class) {
if (helper == null) { if (helper == null) {
helper = new com.fr.design.extra.LoginWebBridge(); helper = new LoginWebBridge();
} }
return helper; return helper;
} }
} }
public static com.fr.design.extra.LoginWebBridge getHelper(WebEngine webEngine) { public int getMessageCount() {
getHelper(); return messageCount;
helper.setEngine(webEngine);
return helper;
} }
private WebEngine webEngine; public void setUILabelInPlugin(UILabel uiLabel) {
this.pluginuiLabel = uiLabel;
}
public void setEngine(WebEngine webEngine) { public void setQqDialog(UIDialog qqDialog) {
this.webEngine = webEngine; closeQQWindow();
this.qqDialog = qqDialog;
} }
public void setDialogHandle(UIDialog uiDialog) { public void setDialogHandle(UIDialog uiDialog) {
closeWindow();
this.uiDialog = uiDialog; this.uiDialog = uiDialog;
} }
@ -98,50 +95,56 @@ public class LoginWebBridge {
this.uiLabel = uiLabel; this.uiLabel = uiLabel;
} }
public LoginWebBridge() {
String username = DesignerEnvManager.getEnvManager().getBBSName();
setUserName(username, uiLabel);
}
/** /**
* 设置显示的用户名 * 设置显示的用户名
*
* @param userName 登录用户名 * @param userName 登录用户名
* @param label label显示 * @param label label显示
*/ */
public void setUserName(String userName, UILabel label) { public void setUserName(String userName, UILabel label) {
if (uiLabel == null) { if (uiLabel == null) {
this.uiLabel = label; this.uiLabel = label;
} }
if(StringUtils.isEmpty(userName)){ if (StringUtils.isEmpty(userName)) {
return; return;
} }
if(!StringUtils.isEmpty(this.userName)){ if (StringUtils.isNotEmpty(this.userName)) {
updateMessageCount(); updateMessageCount();
} }
this.userName = userName; this.userName = userName;
} }
/**
* 测试论坛网络连接
*
* @return
*/
private boolean testConnection() {
HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test"));
return client.isServerAlive();
}
/** /**
* 定时取后台论坛消息 * 定时取后台论坛消息
*/ */
public void updateMessageCount(){ public void updateMessageCount() {
//启动获取消息更新的线程 //启动获取消息更新的线程
//登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数. //登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数.
Thread updateMessageThread = new Thread(new Runnable() { Thread updateMessageThread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
sleep(CHECK_MESSAGE_TIME); sleep(CHECK_MESSAGE_TIME);
while(StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())){ while (StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())) {
HashMap<String, String> para = new HashMap<>(); HashMap<String, String> para = new HashMap<>();
int uid = DesignerEnvManager.getEnvManager().getBbsUid(); int uid = DesignerEnvManager.getEnvManager().getBbsUid();
para.put("uid", String.valueOf(uid)); para.put("uid", String.valueOf(uid));
HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para); HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para);
getMessage.asGet(); getMessage.asGet();
if(getMessage.isServerAlive()){ if (getMessage.isServerAlive()) {
try { try {
String res = getMessage.getResponseText(); String res = getMessage.getResponseText();
if (res.equals(FAILED_MESSAGE_STATUS)) { if (res.equals(FAILED_MESSAGE_STATUS)) {
}else { } else {
JSONObject jo = new JSONObject(res); JSONObject jo = new JSONObject(res);
if (jo.getString("status").equals(SUCCESS_MESSAGE_STATUS)) { if (jo.getString("status").equals(SUCCESS_MESSAGE_STATUS)) {
setMessageCount(Integer.parseInt(jo.getString("message"))); setMessageCount(Integer.parseInt(jo.getString("message")));
@ -160,6 +163,7 @@ public class LoginWebBridge {
/** /**
* 设置获取的消息长度并设置显示 * 设置获取的消息长度并设置显示
*
* @param count * @param count
*/ */
public void setMessageCount(int count) { public void setMessageCount(int count) {
@ -177,7 +181,7 @@ public class LoginWebBridge {
uiLabel.setText(sb.toString()); uiLabel.setText(sb.toString());
} }
private String encode(String str){ private String encode(String str) {
try { try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8); return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -185,7 +189,7 @@ public class LoginWebBridge {
} }
} }
private void sleep(long millis){ private void sleep(long millis) {
try { try {
Thread.sleep(millis); Thread.sleep(millis);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -199,7 +203,7 @@ public class LoginWebBridge {
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());
} }
} }
@ -210,13 +214,14 @@ public class LoginWebBridge {
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());
} }
} }
/** /**
* 设计器端的用户登录 * 设计器端的用户登录
*
* @param username 用户名 * @param username 用户名
* @param password 密码 * @param password 密码
* @return 登录信息标志 * @return 登录信息标志
@ -227,9 +232,10 @@ public class LoginWebBridge {
/** /**
* 插件管理的用户登录部分 * 插件管理的用户登录部分
*
* @param username 用户名 * @param username 用户名
* @param password 密码 * @param password 密码
* @param uiLabel 设计器端的label * @param uiLabel 设计器端的label
* @return 登录信息标志 * @return 登录信息标志
*/ */
public String pluginManageLogin(String username, String password, UILabel uiLabel) { public String pluginManageLogin(String username, String password, UILabel uiLabel) {
@ -238,9 +244,10 @@ public class LoginWebBridge {
/** /**
* 登录操作 * 登录操作
*
* @param username 用户名 * @param username 用户名
* @param password 密码 * @param password 密码
* @param uiLabel 两边的label显示 * @param uiLabel 两边的label显示
* @return 登录信息标志 * @return 登录信息标志
*/ */
public String login(String username, String password, UILabel uiLabel) { public String login(String username, String password, UILabel uiLabel) {
@ -271,8 +278,8 @@ public class LoginWebBridge {
/** /**
* 更新后台的用户信息 * 更新后台的用户信息
*
* @param username 用户名 * @param username 用户名
* @param password 密码
*/ */
public void updateUserInfo(String username) { public void updateUserInfo(String username) {
this.userName = username; this.userName = username;
@ -280,6 +287,7 @@ public class LoginWebBridge {
/** /**
* 关闭窗口并且重新赋值 * 关闭窗口并且重新赋值
*
* @param username * @param username
*/ */
public void loginSuccess(String username, UILabel uiLabel) { public void loginSuccess(String username, UILabel uiLabel) {
@ -294,13 +302,7 @@ public class LoginWebBridge {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
//弹出qq登录的窗口 WebViewDlgHelper.createQQLoginDialog();
QQLoginPane managerPane = new QQLoginPane();
UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(),managerPane);
QQLoginWebBridge.getHelper().setDialogHandle(uiDialog);
QQLoginWebBridge.getHelper().setQQDialogHandle(qqlog);
QQLoginWebBridge.getHelper().setUILabel(uiLabel);
qqlog.setVisible(true);
} }
}); });
} }
@ -326,12 +328,55 @@ public class LoginWebBridge {
} else { } else {
return UNKNOWN_ERROR;//未知错误,-3 return UNKNOWN_ERROR;//未知错误,-3
} }
}else { } else {
return NET_FAILED; return NET_FAILED;
} }
}catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FRContext.getLogger().info(e.getMessage());
} }
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
/**
* 关闭QQ授权窗口
*/
public void closeQQWindow() {
if (qqDialog != null) {
qqDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
qqDialog.setVisible(false);
}
}
/**
* 获取用户信息
*
* @param userInfo
*/
public void getLoginInfo(String userInfo) {
org.json.JSONObject jo = new org.json.JSONObject(userInfo);
String status = jo.get("status").toString();
if (status.equals(LOGIN_SUCCESS)) {
String username = jo.get("username").toString();
int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString());
closeWindow();
closeQQWindow();
pluginuiLabel.setText(username);
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setBbsUid(uid);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
} else if (status.equals(LOGIN_FAILED)) {
//账号没有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;
}
}
} }

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;
}
}
}

129
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,51 +80,56 @@ 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 public Boolean call(String msg) {
Boolean confirmed = confirm(primaryStage, msg, installHome, webView);
return confirmed;
}
});
webEngine.locationProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, final String oldValue, String newValue) {
disableLink(webEngine);
// webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转
if (ComparatorUtils.equals(newValue, "file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html") || ComparatorUtils.equals(newValue, SiteCenter.getInstance().acquireUrlByKind("bbs.mobile"))) {
return;
}
QQLoginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue);
}
});
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override @Override
public void handle(WebEvent<String> event) { public Boolean call(String msg) {
showAlert(event.getData()); Boolean confirmed = confirm(primaryStage, msg, webView);
return confirmed;
} }
}); });
webEngine.getLoadWorker().stateProperty().addListener( configWebEngine();
new ChangeListener<Worker.State>() {
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) {
window = (JSObject) webEngine.executeScript("window");
window.setMember("QQLoginHelper", QQLoginWebBridge.getHelper(webEngine));
}
}
}
);
webView.setContextMenuEnabled(false);//屏蔽右键 webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView); root.setCenter(webView);
} }
}); });
} }
private void configWebEngine() {
webEngine.locationProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, final String oldValue, String newValue) {
disableLink(webEngine);
// webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转
if (ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, SiteCenter.getInstance().acquireUrlByKind("bbs.mobile"))) {
return;
}
LoginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue);
}
});
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
showAlert(event.getData());
}
});
webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<Worker.State>() {
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) {
window = (JSObject) webEngine.executeScript("window");
window.setMember("QQLoginHelper", LoginWebBridge.getHelper());
}
}
}
);
}
private void showAlert(final String message) { private void showAlert(final String message) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
@ -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();

13
designer_base/src/com/fr/design/formula/VariableResolverAdapter.java

@ -4,12 +4,16 @@ import com.fr.base.ConfigManager;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.base.ConfigManagerProvider; import com.fr.base.ConfigManagerProvider;
import com.fr.plugin.ExtraClassManager;
import com.fr.script.ScriptConstants; import com.fr.script.ScriptConstants;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.fun.BuiltInParametersProvider;
import com.fr.stable.script.CalculatorProvider; import com.fr.stable.script.CalculatorProvider;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
public abstract class VariableResolverAdapter implements VariableResolver { public abstract class VariableResolverAdapter implements VariableResolver {
private static final int TABLE_DATA_PARA = 0; private static final int TABLE_DATA_PARA = 0;
@ -21,7 +25,7 @@ public abstract class VariableResolverAdapter implements VariableResolver {
* @return 内置参数 * @return 内置参数
*/ */
public String[] resolveCurReportVariables() { public String[] resolveCurReportVariables() {
return new String[] { ScriptConstants.SUMMARY_TAG + "page_number", String [] variables = new String[] { ScriptConstants.SUMMARY_TAG + "page_number",
ScriptConstants.SUMMARY_TAG + "totalPage_number", ScriptConstants.SUMMARY_TAG + "totalPage_number",
// 下面是权限相关的参数 // 下面是权限相关的参数
ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_USERNAME, ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_AUTHORITY, ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_USERNAME, ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_AUTHORITY,
@ -32,6 +36,13 @@ public abstract class VariableResolverAdapter implements VariableResolver {
CalculatorProvider.REPORT_NAME, CalculatorProvider.FORMLET_NAME, CalculatorProvider.SERVLET_URL, CalculatorProvider.SERVER_SCHEMA, CalculatorProvider.SERVER_NAME, CalculatorProvider.REPORT_NAME, CalculatorProvider.FORMLET_NAME, CalculatorProvider.SERVLET_URL, CalculatorProvider.SERVER_SCHEMA, CalculatorProvider.SERVER_NAME,
CalculatorProvider.SERVER_PORT, CalculatorProvider.SERVER_URL, CalculatorProvider.CONTEXT_PATH, CalculatorProvider.SESSION_ID CalculatorProvider.SERVER_PORT, CalculatorProvider.SERVER_URL, CalculatorProvider.CONTEXT_PATH, CalculatorProvider.SESSION_ID
}; };
Set<BuiltInParametersProvider> set = ExtraClassManager.getInstance().getArray(BuiltInParametersProvider.XML_TAG);
for (BuiltInParametersProvider provider : set) {
return (String[]) ArrayUtils.addAll(variables, new String []{
ScriptConstants.DETAIL_TAG + provider.getParametersName()
});
}
return variables;
} }
private Parameter[] getCurrentModeParameters(int type) { private Parameter[] getCurrentModeParameters(int type) {

52
designer_base/src/com/fr/design/gui/style/BorderPane.java

@ -51,34 +51,16 @@ public class BorderPane extends AbstractBasicStylePane {
} }
protected void initComponents() { protected void initComponents() {
topToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png")); initButtonsWithIcon();
leftToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png"));
bottomToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"));
rightToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"));
horizontalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"));
verticalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"));
this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
this.currentLineColorPane = new NewColorSelectBox(100);
this.setLayout(new BorderLayout(0, 6)); this.setLayout(new BorderLayout(0, 6));
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double[] columnSize1 = {p, f}, rowSize1 = {p, p};
double f = TableLayout.FILL;
double[] columnSize1 = {p, f};
double[] rowSize1 = {p, p};
Component[][] components1 = new Component[][]{ Component[][] components1 = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Style") + ":"), currentLineCombo}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Style") + ":"), currentLineCombo},
new Component[]{new UILabel(Inter.getLocText("Color") + ":"), currentLineColorPane}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Color") + ":"), currentLineColorPane},
}; };
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components1, rowSize1, columnSize1); JPanel northPane = TableLayoutHelper.createTableLayoutPane(components1, rowSize1, columnSize1);
double[] columnSize2 = {p, f}, rowSize2 = {p, p};
double[] columnSize2 = {p, f};
double[] rowSize2 = {p, p};
JPanel externalPane = new JPanel(new GridLayout(0, 4)); JPanel externalPane = new JPanel(new GridLayout(0, 4));
externalPane.add(topToggleButton); externalPane.add(topToggleButton);
externalPane.add(leftToggleButton); externalPane.add(leftToggleButton);
@ -87,23 +69,15 @@ public class BorderPane extends AbstractBasicStylePane {
JPanel insidePane = new JPanel(new GridLayout(0, 2)); JPanel insidePane = new JPanel(new GridLayout(0, 2));
insidePane.add(horizontalToggleButton); insidePane.add(horizontalToggleButton);
insidePane.add(verticalToggleButton); insidePane.add(verticalToggleButton);
Component[][] components2 = new Component[][]{ Component[][] components2 = new Component[][]{
new Component[]{outerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/out.png")), innerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/in.png"))}, new Component[]{outerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/out.png")), innerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/in.png"))},
new Component[]{externalPane, insidePane,} new Component[]{externalPane, insidePane,}
}; };
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components2, rowSize2, columnSize2); JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components2, rowSize2, columnSize2);
this.setLayout(new BorderLayout(0, 6)); this.setLayout(new BorderLayout(0, 6));
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
this.currentLineColorPane.setSelectObject(Color.BLACK);
outerToggleButton.addChangeListener(new ChangeListener() { outerToggleButton.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
boolean value = outerToggleButton.isSelected(); boolean value = outerToggleButton.isSelected();
@ -113,9 +87,7 @@ public class BorderPane extends AbstractBasicStylePane {
rightToggleButton.setSelected(value); rightToggleButton.setSelected(value);
} }
}); });
innerToggleButton.addChangeListener(new ChangeListener() { innerToggleButton.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
boolean value = innerToggleButton.isSelected(); boolean value = innerToggleButton.isSelected();
@ -123,12 +95,22 @@ public class BorderPane extends AbstractBasicStylePane {
verticalToggleButton.setSelected(value); verticalToggleButton.setSelected(value);
} }
}); });
}
private void initButtonsWithIcon(){
topToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png"));
leftToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png"));
bottomToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"));
rightToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"));
horizontalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"));
verticalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"));
this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
this.currentLineColorPane = new NewColorSelectBox(100);
} }
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return Inter.getLocText("Border"); return Inter.getLocText("FR-Designer_Border");
} }
public void populate(Style style) { public void populate(Style style) {

BIN
designer_base/src/com/fr/design/images/control/tab/end.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
designer_base/src/com/fr/design/images/control/tab/end_not.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

BIN
designer_base/src/com/fr/design/images/control/tab/first.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
designer_base/src/com/fr/design/images/control/tab/first_not.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
designer_base/src/com/fr/design/images/control/tab/next.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
designer_base/src/com/fr/design/images/control/tab/next_not.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

BIN
designer_base/src/com/fr/design/images/control/tab/prev.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

BIN
designer_base/src/com/fr/design/images/control/tab/prev_not.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

7
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -529,12 +529,13 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
} }
protected boolean saveNewFile(FILE editingFILE, String oldName){ protected boolean saveNewFile(FILE editingFILE, String oldName){
this.editingFILE = editingFILE; // 在保存之前,初始化 templateID
initForCollect(); // 如果保存新模板(新建模板直接保存,或者另存为),则添加 templateID
this.editingFILE = editingFILE;
boolean result = this.saveFile(); boolean result = this.saveFile();
if (result) { if (result) {
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
initForCollect(); // 如果保存新模板(新建模板直接保存,或者另存为),则添加 templateID
collectInfo(); collectInfo();
} }
//更换最近打开 //更换最近打开
@ -1028,4 +1029,4 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
return uiButtons; return uiButtons;
} }
} }

15
designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java

@ -26,17 +26,16 @@ import java.awt.geom.Rectangle2D;
public class PatternBackgroundQuickPane extends BackgroundQuickPane { public class PatternBackgroundQuickPane extends BackgroundQuickPane {
private int patternIndex = 0; // pattern setIndex. private int patternIndex = 0; // pattern setIndex.
private final static int DEFAULT_DIM_HEIGHT = 190;
private ColorSelectBox foregroundColorPane; private ColorSelectBox foregroundColorPane;
private ColorSelectBox backgroundColorPane; private ColorSelectBox backgroundColorPane;
private PatternButton[] patternButtonArray; private PatternButton[] patternButtonArray;
public PatternBackgroundQuickPane() { public PatternBackgroundQuickPane() {
this.setLayout(new BorderLayout(0, 4)); this.setLayout(new BorderLayout(0, 4));
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(contentPane, BorderLayout.NORTH); this.add(contentPane, BorderLayout.NORTH);
contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
JPanel typePane2 = new JPanel(); JPanel typePane2 = new JPanel();
contentPane.add(typePane2); contentPane.add(typePane2);
typePane2.setLayout(new GridLayout(0, 8, 1, 1)); typePane2.setLayout(new GridLayout(0, 8, 1, 1));
@ -48,15 +47,11 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
patternButtonGroup.add(patternButtonArray[i]); patternButtonGroup.add(patternButtonArray[i]);
typePane2.add(patternButtonArray[i]); typePane2.add(patternButtonArray[i]);
} }
JPanel colorPane = new JPanel(new GridLayout(0, 2)); JPanel colorPane = new JPanel(new GridLayout(0, 2));
foregroundColorPane = new ColorSelectBox(70); foregroundColorPane = new ColorSelectBox(70);
backgroundColorPane = new ColorSelectBox(70); backgroundColorPane = new ColorSelectBox(70);
foregroundColorPane.setSelectObject(Color.lightGray); colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Foreground") + ":", foregroundColorPane));
backgroundColorPane.setSelectObject(Color.black); colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Background") + ":", backgroundColorPane));
colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane));
colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane));
this.add(colorPane, BorderLayout.CENTER); this.add(colorPane, BorderLayout.CENTER);
foregroundColorPane.addSelectChangeListener(colorChangeListener); foregroundColorPane.addSelectChangeListener(colorChangeListener);
backgroundColorPane.addSelectChangeListener(colorChangeListener); backgroundColorPane.addSelectChangeListener(colorChangeListener);
@ -65,7 +60,7 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize(); Dimension dim = super.getPreferredSize();
dim.height = 190; dim.height = DEFAULT_DIM_HEIGHT;
return dim; return dim;
} }
@ -206,6 +201,6 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return Inter.getLocText("Background-Pattern"); return Inter.getLocText("FR-Designer_Background-Pattern");
} }
} }

356
designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -6,32 +6,56 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.*;
import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.stable.*; import com.fr.stable.*;
import org.json.JSONObject; import com.fr.stable.xml.*;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.json.JSONObject;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.HashMap;
/** /**
* 做模板的过程和耗时收集辅助类 * 做模板的过程和耗时收集辅助类
* Created by plough on 2017/2/21. * Created by plough on 2017/2/21.
*/ */
public class TemplateInfoCollector<T extends IOFile> implements Serializable { public class TemplateInfoCollector<T extends IOFile> implements Serializable, XMLReadable, XMLWriter {
private static final String FILE_NAME = "tplInfo.ser"; private static final String FILE_NAME = "tpl.info";
private static final String OBJECT_FILE_NAME = "tplInfo.ser";
private static TemplateInfoCollector instance; private static TemplateInfoCollector instance;
private HashMap<String, HashMap<String, Object>> templateInfoList; private Map<String, HashMap<String, Object>> templateInfoList;
private String designerOpenDate; //设计器最近一次打开日期 private String designerOpenDate; //设计器最近一次打开日期
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数 private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private static final int ONE_THOUSAND = 1000; private static final int ONE_THOUSAND = 1000;
static final long serialVersionUID = 2007L; static final long serialVersionUID = 2007L;
private static final String XML_DESIGNER_OPEN_DATE = "DesignerOpenDate";
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_TEMPLATE_INFO = "TemplateInfo";
private static final String XML_PROCESS_MAP = "processMap";
private static final String XML_CONSUMING_MAP = "consumingMap";
private static final String ATTR_DAY_COUNT = "day_count";
private static final String ATTR_TEMPLATE_ID = "templateID";
private static final String ATTR_PROCESS = "process";
private static final String ATTR_FLOAT_COUNT = "float_count";
private static final String ATTR_WIDGET_COUNT = "widget_count";
private static final String ATTR_CELL_COUNT = "cell_count";
private static final String ATTR_BLOCK_COUNT = "block_count";
private static final String ATTR_REPORT_TYPE = "report_type";
private static final String ATTR_ACTIVITYKEY = "activitykey";
private static final String ATTR_JAR_TIME = "jar_time";
private static final String ATTR_CREATE_TIME = "create_time";
private static final String ATTR_UUID = "uuid";
private static final String ATTR_TIME_CONSUME = "time_consume";
private static final String ATTR_VERSION = "version";
private static final String ATTR_USERNAME = "username";
private static final String JSON_CONSUMING_MAP = "jsonConsumingMap";
private static final String JSON_PROCESS_MAP = "jsonProcessMap";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private TemplateInfoCollector() { private TemplateInfoCollector() {
@ -61,29 +85,57 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME));
} }
private static File getObjectInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), OBJECT_FILE_NAME));
}
public static TemplateInfoCollector getInstance() { public static TemplateInfoCollector getInstance() {
if (instance == null) { if (instance == null) {
// 先尝试从文件读取 instance = new TemplateInfoCollector();
try{ readXMLFile(instance, getInfoFile());
ObjectInputStream is = new ObjectInputStream(new FileInputStream(getInfoFile())); // 兼容过渡。如果没有新文件,则从老文件读取数据。以后都是读写新的 xml 文件
instance = (TemplateInfoCollector) is.readObject(); if (!getInfoFile().exists() && getObjectInfoFile().exists()) {
} catch (FileNotFoundException ex) { try {
// 如果之前没有存储过,则创建新对象 ObjectInputStream is = new ObjectInputStream(new FileInputStream(getObjectInfoFile()));
instance = new TemplateInfoCollector(); instance = (TemplateInfoCollector) is.readObject();
} catch (InvalidClassException ex) { } catch (Exception ex) {
// 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖) // 什么也不做,instance 使用新值
// 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现 }
FRLogger.getLogger().info(ex.getMessage());
FRLogger.getLogger().info("use a new instance");
instance = new TemplateInfoCollector();
}
catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage(), ex);
} }
} }
return instance; return instance;
} }
private static void readXMLFile(XMLReadable xmlReadable, File xmlFile){
if (xmlFile == null || !xmlFile.exists()) {
return;
}
String charset = EncodeConstants.ENCODING_UTF_8;
try {
String fileContent = getFileContent(xmlFile);
InputStream xmlInputStream = new ByteArrayInputStream(fileContent.getBytes(charset));
InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset);
XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader);
if (xmlReader != null) {
xmlReader.readXMLObject(xmlReadable);
}
xmlInputStream.close();
} catch (FileNotFoundException e) {
FRContext.getLogger().error(e.getMessage());
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
} catch (XMLStreamException e) {
FRContext.getLogger().error(e.getMessage());
}
}
private static String getFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException{
InputStream is = new FileInputStream(xmlFile);
return IOUtils.inputStream2String(is);
}
private boolean shouldCollectInfo() { private boolean shouldCollectInfo() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据 if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
return false; return false;
@ -106,8 +158,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String loadProcess(T t) { public String loadProcess(T t) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get("processMap"); HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get(XML_PROCESS_MAP);
return (String)processMap.get("process"); return (String)processMap.get(ATTR_PROCESS);
} }
/** /**
@ -122,17 +174,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/ */
private void saveInfo() { private void saveInfo() {
try { try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile())); FileOutputStream out = new FileOutputStream(getInfoFile());
String log = ""; XMLTools.writeOutputStreamXML(this, out);
int count = 1;
for (String key : templateInfoList.keySet()) {
String createTime = ((HashMap)templateInfoList.get(key).get("consumingMap")).get("create_time").toString();
log += (count + ". id: " + key + " " + createTime + "\n" + templateInfoList.get(key).toString() + "\n");
count ++;
}
FRLogger.getLogger().info("writing tplInfo: \n" + log);
os.writeObject(instance);
os.close();
} catch (Exception ex) { } catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage()); FRLogger.getLogger().error(ex.getMessage());
} }
@ -145,8 +188,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (designerOpenFirstTime()) { if (designerOpenFirstTime()) {
for (String key : templateInfoList.keySet()) { for (String key : templateInfoList.keySet()) {
HashMap<String, Object> templateInfo = templateInfoList.get(key); HashMap<String, Object> templateInfo = templateInfoList.get(key);
int dayCount = (int)templateInfo.get("day_count") + 1; int dayCount = (int)templateInfo.get(ATTR_DAY_COUNT) + 1;
templateInfo.put("day_count", dayCount); templateInfo.put(ATTR_DAY_COUNT, dayCount);
} }
setDesignerOpenDate(); setDesignerOpenDate();
} }
@ -170,21 +213,20 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (inList(t)) { // 已有记录 if (inList(t)) { // 已有记录
templateInfo = templateInfoList.get(t.getTemplateID()); templateInfo = templateInfoList.get(t.getTemplateID());
// 更新 conusmingMap // 更新 conusmingMap
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get("consumingMap"); HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
timeConsume += (long)consumingMap.get("time_consume"); // 加上之前的累计编辑时间 timeConsume += (long)consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
consumingMap.put("time_consume", timeConsume); consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
} }
else { // 新增 else { // 新增
templateInfo = new HashMap<>(); templateInfo = new HashMap<>();
templateInfo.put("consumingMap", getNewConsumingMap(templateID, openTime, timeConsume)); templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume));
} }
// 直接覆盖 processMap // 直接覆盖 processMap
templateInfo.put("processMap", getProcessMap(templateID, jt)); templateInfo.put(XML_PROCESS_MAP, getProcessMap(templateID, jt));
// 保存模板时,让 day_count 归零 // 保存模板时,让 day_count 归零
templateInfo.put("day_count", 0); templateInfo.put(ATTR_DAY_COUNT, 0);
templateInfoList.put(templateID, templateInfo); templateInfoList.put(templateID, templateInfo);
@ -200,14 +242,14 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String jarTime = GeneralUtils.readBuildNO(); String jarTime = GeneralUtils.readBuildNO();
String version = ProductConstants.VERSION; String version = ProductConstants.VERSION;
consumingMap.put("username", username); consumingMap.put(ATTR_USERNAME, username);
consumingMap.put("uuid", uuid); consumingMap.put(ATTR_UUID, uuid);
consumingMap.put("activitykey", activitykey); consumingMap.put(ATTR_ACTIVITYKEY, activitykey);
consumingMap.put("templateID", templateID); consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put("create_time", createTime); consumingMap.put(ATTR_CREATE_TIME, createTime);
consumingMap.put("time_consume", timeConsume); consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
consumingMap.put("jar_time", jarTime); consumingMap.put(ATTR_JAR_TIME, jarTime);
consumingMap.put("version", version); consumingMap.put(ATTR_VERSION, version);
return consumingMap; return consumingMap;
} }
@ -215,15 +257,15 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private HashMap<String, Object> getProcessMap(String templateID, JTemplate jt) { private HashMap<String, Object> getProcessMap(String templateID, JTemplate jt) {
HashMap<String, Object> processMap = new HashMap<>(); HashMap<String, Object> processMap = new HashMap<>();
processMap.put("templateID", templateID); processMap.put(ATTR_TEMPLATE_ID, templateID);
processMap.put("process", jt.getProcess()); processMap.put(ATTR_PROCESS, jt.getProcess());
TemplateProcessInfo info = jt.getProcessInfo(); TemplateProcessInfo info = jt.getProcessInfo();
processMap.put("report_type", info.getReportType()); processMap.put(ATTR_REPORT_TYPE, info.getReportType());
processMap.put("cell_count", info.getCellCount()); processMap.put(ATTR_CELL_COUNT, info.getCellCount());
processMap.put("float_count", info.getFloatCount()); processMap.put(ATTR_FLOAT_COUNT, info.getFloatCount());
processMap.put("block_count", info.getBlockCount()); processMap.put(ATTR_BLOCK_COUNT, info.getBlockCount());
processMap.put("widget_count", info.getWidgetCount()); processMap.put(ATTR_WIDGET_COUNT, info.getWidgetCount());
return processMap; return processMap;
} }
@ -237,14 +279,11 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
String processUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; String processUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single";
ArrayList<HashMap<String, String>> completeTemplatesInfo = getCompleteTemplatesInfo(); ArrayList<HashMap<String, String>> completeTemplatesInfo = getCompleteTemplatesInfo();
for (HashMap<String, String> templateInfo : completeTemplatesInfo) { for (HashMap<String, String> templateInfo : completeTemplatesInfo) {
String jsonConsumingMap = templateInfo.get("jsonConsumingMap"); String jsonConsumingMap = templateInfo.get(JSON_CONSUMING_MAP);
String jsonProcessMap = templateInfo.get("jsonProcessMap"); String jsonProcessMap = templateInfo.get(JSON_PROCESS_MAP);
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) { if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
// 清空记录 // 清空记录
FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); removeFromTemplateInfoList(templateInfo.get(ATTR_TEMPLATE_ID));
removeFromTemplateInfoList(templateInfo.get("templateID"));
} else {
FRLogger.getLogger().info("send template info failed, will try next time, " + templateInfo.get("templateID"));
} }
} }
saveInfo(); saveInfo();
@ -264,7 +303,12 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
} }
String res = httpClient.getResponseText(); String res = httpClient.getResponseText();
boolean success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); boolean success;
try {
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception ex) {
success = false;
}
return success; return success;
} }
@ -277,21 +321,21 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
for (String key : templateInfoList.keySet()) { for (String key : templateInfoList.keySet()) {
HashMap<String, Object> templateInfo = templateInfoList.get(key); HashMap<String, Object> templateInfo = templateInfoList.get(key);
if ((int)templateInfo.get("day_count") <= COMPLETE_DAY_COUNT) { // 未完成模板 if ((int)templateInfo.get(ATTR_DAY_COUNT) <= COMPLETE_DAY_COUNT) { // 未完成模板
continue; continue;
} }
if (isTestTemplate(templateInfo)) { if (isTestTemplate(templateInfo)) {
testTemplateKeys.add(key); testTemplateKeys.add(key);
continue; continue;
} }
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get("consumingMap"); HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap"); HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
String jsonConsumingMap = new JSONObject(consumingMap).toString(); String jsonConsumingMap = new JSONObject(consumingMap).toString();
String jsonProcessMap = new JSONObject(processMap).toString(); String jsonProcessMap = new JSONObject(processMap).toString();
HashMap<String, String> jsonTemplateInfo = new HashMap<>(); HashMap<String, String> jsonTemplateInfo = new HashMap<>();
jsonTemplateInfo.put("jsonConsumingMap", jsonConsumingMap); jsonTemplateInfo.put(JSON_CONSUMING_MAP, jsonConsumingMap);
jsonTemplateInfo.put("jsonProcessMap", jsonProcessMap); jsonTemplateInfo.put(JSON_PROCESS_MAP, jsonProcessMap);
jsonTemplateInfo.put("templateID", key); jsonTemplateInfo.put(ATTR_TEMPLATE_ID, key);
completeTemplatesInfo.add(jsonTemplateInfo); completeTemplatesInfo.add(jsonTemplateInfo);
} }
// 删除测试模板 // 删除测试模板
@ -303,17 +347,16 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private void removeFromTemplateInfoList(String key) { private void removeFromTemplateInfoList(String key) {
templateInfoList.remove(key); templateInfoList.remove(key);
FRLogger.getLogger().info(key + " is removed...");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) { private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap"); HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
int reportType = (int)processMap.get("report_type"); int reportType = (int)processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int)processMap.get("cell_count"); int cellCount = (int)processMap.get(ATTR_CELL_COUNT);
int floatCount = (int)processMap.get("float_count"); int floatCount = (int)processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int)processMap.get("block_count"); int blockCount = (int)processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int)processMap.get("widget_count"); int widgetCount = (int)processMap.get(ATTR_WIDGET_COUNT);
boolean isTestTemplate = false; boolean isTestTemplate = false;
if (reportType == 0) { // 普通报表 if (reportType == 0) { // 普通报表
isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
@ -325,6 +368,157 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
return isTestTemplate; return isTestTemplate;
} }
@SuppressWarnings("unchecked")
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
try {
String name = reader.getTagName();
if (XML_DESIGNER_OPEN_DATE.equals(name)) {
this.designerOpenDate = reader.getElementValue();
} else if(XML_TEMPLATE_INFO_LIST.equals(name)){
readTemplateInfoList(reader);
}
} catch (Exception ex) {
// 什么也不做,使用默认值
}
}
}
private void readTemplateInfoList(XMLableReader reader) {
reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader reader) {
if (XML_TEMPLATE_INFO.equals(reader.getTagName())) {
TemplateInfo templateInfo = new TemplateInfo();
reader.readXMLObject(templateInfo);
templateInfoList.put(templateInfo.getTemplateID(), templateInfo.getTemplateInfo());
}
}
});
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("TplInfo");
writer.startTAG(XML_DESIGNER_OPEN_DATE);
writer.textNode(designerOpenDate);
writer.end();
writeTemplateInfoList(writer);
writer.end();
}
private void writeTemplateInfoList(XMLPrintWriter writer){
//启停
writer.startTAG(XML_TEMPLATE_INFO_LIST);
for (String templateID : templateInfoList.keySet()) {
new TemplateInfo(templateInfoList.get(templateID)).writeXML(writer);
}
writer.end();
}
private class TemplateInfo implements XMLReadable, XMLWriter {
private int dayCount;
private String templateID;
private HashMap<String, Object> processMap = new HashMap<>();
private HashMap<String, Object> consumingMap = new HashMap<>();
@SuppressWarnings("unchecked")
public TemplateInfo(HashMap<String, Object> templateInfo) {
this.dayCount = (int)templateInfo.get(ATTR_DAY_COUNT);
this.processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
this.consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID);
}
public TemplateInfo() {}
public String getTemplateID() {
return templateID;
}
public HashMap<String, Object> getTemplateInfo() {
HashMap<String, Object> templateInfo = new HashMap<>();
templateInfo.put(XML_PROCESS_MAP, processMap);
templateInfo.put(XML_CONSUMING_MAP, consumingMap);
templateInfo.put(ATTR_DAY_COUNT, dayCount);
return templateInfo;
}
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TEMPLATE_INFO);
if (StringUtils.isNotEmpty(templateID)) {
writer.attr(ATTR_TEMPLATE_ID, this.templateID);
}
if (dayCount >= 0) {
writer.attr(ATTR_DAY_COUNT, this.dayCount);
}
writeProcessMap(writer);
writeConsumingMap(writer);
writer.end();
}
private void writeProcessMap(XMLPrintWriter writer) {
writer.startTAG(XML_PROCESS_MAP);
writer.attr(ATTR_PROCESS, (String)processMap.get(ATTR_PROCESS));
writer.attr(ATTR_FLOAT_COUNT, (int)processMap.get(ATTR_FLOAT_COUNT));
writer.attr(ATTR_WIDGET_COUNT, (int)processMap.get(ATTR_WIDGET_COUNT));
writer.attr(ATTR_CELL_COUNT, (int)processMap.get(ATTR_CELL_COUNT));
writer.attr(ATTR_BLOCK_COUNT, (int)processMap.get(ATTR_BLOCK_COUNT));
writer.attr(ATTR_REPORT_TYPE, (int)processMap.get(ATTR_REPORT_TYPE));
writer.end();
}
private void writeConsumingMap(XMLPrintWriter writer) {
writer.startTAG(XML_CONSUMING_MAP);
writer.attr(ATTR_ACTIVITYKEY, (String)consumingMap.get(ATTR_ACTIVITYKEY));
writer.attr(ATTR_JAR_TIME, (String)consumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_CREATE_TIME, (String)consumingMap.get(ATTR_CREATE_TIME));
writer.attr(ATTR_UUID, (String)consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (long)consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_VERSION, (String)consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String)consumingMap.get(ATTR_USERNAME));
writer.end();
}
public void readXML(XMLableReader reader) {
if (!reader.isChildNode()) {
dayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0);
templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
} else {
try {
String name = reader.getTagName();
if (XML_PROCESS_MAP.equals(name)) {
processMap.put(ATTR_PROCESS, reader.getAttrAsString(ATTR_PROCESS, StringUtils.EMPTY));
processMap.put(ATTR_FLOAT_COUNT, reader.getAttrAsInt(ATTR_FLOAT_COUNT, 0));
processMap.put(ATTR_WIDGET_COUNT, reader.getAttrAsInt(ATTR_WIDGET_COUNT, 0));
processMap.put(ATTR_CELL_COUNT, reader.getAttrAsInt(ATTR_CELL_COUNT, 0));
processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0));
processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
processMap.put(ATTR_TEMPLATE_ID, templateID);
} else if(XML_CONSUMING_MAP.equals(name)){
consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY));
consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY));
consumingMap.put(ATTR_TIME_CONSUME, reader.getAttrAsLong(ATTR_TIME_CONSUME, 0));
consumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0"));
consumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY));
}
} catch (Exception ex) {
// 什么也不做,使用默认值
}
}
}
}
public static void main(String[] args) { public static void main(String[] args) {
TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
tic.sendTemplateInfo(); tic.sendTemplateInfo();

190
designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java

@ -1,112 +1,104 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout; import com.fr.design.dialog.BasicPane;
import java.awt.Color; import com.fr.design.layout.FRGUIPaneFactory;
import java.awt.Dimension; import com.fr.general.Inter;
import javax.swing.JColorChooser; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel; import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
/** /**
* 颜色选择器更多颜色面板 * 颜色选择器更多颜色面板
* @author focus
* *
* @author focus
*/ */
public class ColorSelectDetailPane extends BasicPane{ public class ColorSelectDetailPane extends BasicPane {
private static final int SELECT_PANEL_HEIGHT = 245; private static final int SELECT_PANEL_HEIGHT = 245;
// Selected color // Selected color
private Color color; private Color color;
// 颜色选择器面板 // 颜色选择器面板
JColorChooser selectedPanel; private JColorChooser selectedPanel;
// 最近使用颜色面板 // 最近使用颜色面板
JPanel recentUsePanel; private JPanel recentUsePanel;
// 预览 // 预览
JPanel previewPanel; private JPanel previewPanel;
public JColorChooser getSelectedPanel() { public JColorChooser getSelectedPanel() {
return selectedPanel; return selectedPanel;
} }
public void setSelectedPanel(JColorChooser selectedPanel) { public void setSelectedPanel(JColorChooser selectedPanel) {
this.selectedPanel = selectedPanel; this.selectedPanel = selectedPanel;
} }
public Color getColor() { public Color getColor() {
return color; return color;
} }
public void setColor(Color color) { public void setColor(Color color) {
this.color = color; this.color = color;
} }
public ColorSelectDetailPane() { public ColorSelectDetailPane(Color color) {
super(); if (color == null) {
} color = Color.white;
}
public ColorSelectDetailPane(Color color){ this.color = color;
if(color == null){ initComponents();
color = Color.white; }
}
this.color = color; @Override
initComponents(); protected String title4PopupWindow() {
} return null;
}
@Override
protected String title4PopupWindow() { protected void initComponents() {
return null; this.setLayout(FRGUIPaneFactory.createBorderLayout());
}
// 颜色选择器面板
protected void initComponents() { selectedPanel = new JColorChooser(this.color);
this.setLayout(FRGUIPaneFactory.createBorderLayout()); selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT));
AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels();
// 颜色选择器面板 for (int i = 0; i < choosers.length; i++) {
selectedPanel = new JColorChooser(this.color); selectedPanel.removeChooserPanel(choosers[i]);
selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(),SELECT_PANEL_HEIGHT)); }
AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels(); selectedPanel.setPreviewPanel(new JPanel());
for(int i=0;i<choosers.length;i++){
selectedPanel.removeChooserPanel(choosers[i]); AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel();
} AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel();
selectedPanel.setPreviewPanel(new JPanel()); selectedPanel.addChooserPanel(swatchChooserPanel);
selectedPanel.addChooserPanel(customChooserPanel);
AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel(); this.add(selectedPanel, BorderLayout.NORTH);
AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel();
selectedPanel.addChooserPanel(swatchChooserPanel); // 最近使用面板
selectedPanel.addChooserPanel(customChooserPanel); recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Used"));
this.add(selectedPanel, BorderLayout.NORTH); RecentUseColorPane recent = new RecentUseColorPane(selectedPanel);
recentUsePanel.add(recent);
// 最近使用面板
recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Used")); this.add(recentUsePanel, BorderLayout.CENTER);
RecentUseColorPane recent = new RecentUseColorPane(selectedPanel);
recentUsePanel.add(recent); selectedPanel.setPreviewPanel(new JPanel());
this.add(recentUsePanel,BorderLayout.CENTER); // 预览
previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(Inter.getLocText("FR-Designer_Preview"));
selectedPanel.setPreviewPanel(new JPanel()); final ColorChooserPreview colorChooserPreview = new ColorChooserPreview();
ColorSelectionModel model = selectedPanel.getSelectionModel();
// 预览 model.addChangeListener(new ChangeListener() {
previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(Inter.getLocText("FR-Designer_Preview")); @Override
final ColorChooserPreview colorChooserPreview = new ColorChooserPreview(); public void stateChanged(ChangeEvent e) {
ColorSelectionModel model = selectedPanel.getSelectionModel(); ColorSelectionModel model = (ColorSelectionModel) e.getSource();
model.addChangeListener(new ChangeListener() { colorChooserPreview.setMyColor(model.getSelectedColor());
@Override colorChooserPreview.paint(colorChooserPreview.getGraphics());
public void stateChanged(ChangeEvent e) { }
ColorSelectionModel model = (ColorSelectionModel) e.getSource(); });
colorChooserPreview.setMyColor(model.getSelectedColor()); previewPanel.add(colorChooserPreview);
colorChooserPreview.paint(colorChooserPreview.getGraphics()); this.add(previewPanel, BorderLayout.SOUTH);
} }
});
previewPanel.add(colorChooserPreview);
this.add(previewPanel, BorderLayout.SOUTH);
}
} }

243
designer_base/src/com/fr/design/style/color/ColorSelectPane.java

@ -3,26 +3,23 @@
*/ */
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.Inter;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
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.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
* The pane used to select color * The pane used to select color
@ -30,94 +27,95 @@ import com.fr.design.utils.gui.GUICoreUtils;
public class ColorSelectPane extends TransparentPane implements ColorSelectable { public class ColorSelectPane extends TransparentPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L; private static final long serialVersionUID = -8634152305687249392L;
private Color color = null; //color private Color color = null; //color
//color setting action. //color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>(); private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
ColorSelectDetailPane pane;
/* default */ ColorSelectDetailPane pane;
/** /**
* Constructor. * Constructor.
*/ */
public ColorSelectPane() { public ColorSelectPane() {
super(true); super(true);
initialCompents(true); initialCompents(true);
} }
public ColorSelectPane(boolean isSupportTransparent) { public ColorSelectPane(boolean isSupportTransparent) {
super(isSupportTransparent); super(isSupportTransparent);
initialCompents(isSupportTransparent); initialCompents(isSupportTransparent);
} }
private void initialCompents(boolean isSupportTransparent) { private void initialCompents(boolean isSupportTransparent) {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) { if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency")); UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH); this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() { transpanrentButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
doTransparent(); doTransparent();
} }
}); });
} }
// center // center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
centerPane.add(getRow1Pane()); centerPane.add(getRow1Pane());
JPanel menuColorPane1 = getMenuColorPane(); JPanel menuColorPane1 = getMenuColorPane();
centerPane.add(menuColorPane1); centerPane.add(menuColorPane1);
Color[] colorArray = this.getColorArray(); Color[] colorArray = this.getColorArray();
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i]; Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i];
menuColorPane1.add(new ColorCell(color, this)); menuColorPane1.add(new ColorCell(color, this));
} }
centerPane.add(Box.createVerticalStrut(1)); centerPane.add(Box.createVerticalStrut(1));
UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color")); UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
customButton.addMouseListener(new MouseAdapter() { customButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
customButtonPressed(); customButtonPressed();
} }
}); });
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));
centerPane1.add(customButton, BorderLayout.NORTH); centerPane1.add(customButton, BorderLayout.NORTH);
centerPane.add(centerPane1); centerPane.add(centerPane1);
} }
protected JPanel getMenuColorPane() { protected JPanel getMenuColorPane() {
JPanel menuColorPane = new JPanel(); JPanel menuColorPane = new JPanel();
menuColorPane.setLayout(new GridLayout(5, 8, 1, 1)); menuColorPane.setLayout(new GridLayout(5, 8, 1, 1));
menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
return menuColorPane; return menuColorPane;
} }
// 第一行,1个取色按钮 + 7个最近使用的颜色 // 第一行,1个取色按钮 + 1个留空的单元格 + 6个最近使用的颜色
protected JPanel getRow1Pane() { protected JPanel getRow1Pane() {
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7 row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
// 最近使用 // 最近使用
UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, true); UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, this, true, true);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane()); row1Pane.add(usedColorPane.getPane());
return row1Pane; return row1Pane;
} }
protected Color[] getColorArray(){ protected Color[] getColorArray() {
return ColorFactory.MenuColors; return ColorFactory.MenuColors;
} }
@ -125,15 +123,16 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/** /**
* Add change listener. * Add change listener.
* 增加监听 * 增加监听
* @param 监听 *
* @param changeListener
*/ */
public void addChangeListener(ChangeListener changeListener) { public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener); this.colorChangeListenerList.add(changeListener);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Color"; return "Color";
} }
/** /**
@ -166,38 +165,36 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/** /**
* 选中颜色 * 选中颜色
* @param 颜色单元格
*
*/ */
@Override @Override
public void colorSetted(ColorCell colorCell) { public void colorSetted(ColorCell colorCell) {
colorCell.repaint(); colorCell.repaint();
} }
/** /**
* 初始化中央面板 * 初始化中央面板
* @param centerPane 中央面板 *
* * @param centerPane 中央面板
*/ */
@Override @Override
public void initCenterPaneChildren(JPanel centerPane) { public void initCenterPaneChildren(JPanel centerPane) {
GUICoreUtils.initCenterPaneChildren(centerPane, this); GUICoreUtils.initCenterPaneChildren(centerPane, this);
} }
/** /**
* 透明 * 透明
*/ */
@Override @Override
public void doTransparent() { public void doTransparent() {
this.setColor(null); this.setColor(null);
} }
/** /**
* 更多颜色 * 更多颜色
*/ */
@Override @Override
public void customButtonPressed() { public void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE); pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
} }
} }

386
designer_base/src/com/fr/design/style/color/NewColorSelectPane.java

@ -1,215 +1,205 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.constants.UIConstants;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter; import com.fr.general.Inter;
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.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
*
* @author zhou * @author zhou
* @since 2012-5-29上午10:39:35 * @since 2012-5-29上午10:39:35
*/ */
public class NewColorSelectPane extends BasicPane implements ColorSelectable { public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L; private static final long serialVersionUID = -8634152305687249392L;
private Color color = null; // color private Color color = null; // color
// color setting action. // color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>(); private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
// 颜色选择器 // 颜色选择器
private ColorSelectDetailPane pane; private ColorSelectDetailPane pane;
// 是否支持透明 // 是否支持透明
private boolean isSupportTransparent; private boolean isSupportTransparent;
private final static int TRANSPANENT_WINDOW_HEIGHT = 165; private final static int TRANSPANENT_WINDOW_HEIGHT = 165;
private final static int WINDWO_HEIGHT = 150; private final static int WINDWO_HEIGHT = 150;
// 最近使用颜色 // 最近使用颜色
UsedColorPane usedColorPane; private UsedColorPane usedColorPane;
/** /**
* Constructor. * Constructor.
*/ */
public NewColorSelectPane() { public NewColorSelectPane() {
this(false); this(false);
} }
/** /**
* Constructor. * Constructor.
*/ */
public NewColorSelectPane(boolean isSupportTransparent) { public NewColorSelectPane(boolean isSupportTransparent) {
this.isSupportTransparent = isSupportTransparent; this.isSupportTransparent = isSupportTransparent;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) { if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency")); UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH); this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() { transpanrentButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
doTransparent(); doTransparent();
} }
}); });
} }
// center // center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
// 第一行 // 第一行
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7 row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
centerPane.add(row1Pane); centerPane.add(row1Pane);
// 最近使用 // 最近使用
usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, false); usedColorPane = new UsedColorPane(1, 8, 1, this, true, false);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane()); row1Pane.add(usedColorPane.getPane());
JPanel menuColorPane1 = new JPanel(); JPanel menuColorPane1 = new JPanel();
centerPane.add(menuColorPane1); centerPane.add(menuColorPane1);
menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1)); menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1));
menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
for (int i = 0; i < ColorFactory.MenuColors.length; i++) { for (int i = 0; i < ColorFactory.MenuColors.length; i++) {
menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this)); menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this));
} }
centerPane.add(Box.createVerticalStrut(1)); centerPane.add(Box.createVerticalStrut(1));
// mod by anchore 16/11/16 // mod by anchore 16/11/16
UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color")); UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
//UIButton customButton = new UIButton(Inter.getLocText(new String[]{"More", "Color"}) + "...");
customButton.addMouseListener(new MouseAdapter() {
customButton.addMouseListener(new MouseAdapter() { @Override
@Override public void mousePressed(MouseEvent e) {
public void mousePressed(MouseEvent e) { customButtonPressed();
customButtonPressed(); }
} });
}); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8));
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8)); centerPane1.add(customButton, BorderLayout.NORTH);
centerPane1.add(customButton, BorderLayout.NORTH); centerPane.add(centerPane1);
centerPane.add(centerPane1); }
}
/**
* 添加监听
/** *
* 添加监听 * @param 监听列表 Add change listener.
* @param 监听列表 */
* Add change listener. public void addChangeListener(ChangeListener changeListener) {
*/ this.colorChangeListenerList.add(changeListener);
public void addChangeListener(ChangeListener changeListener) { }
this.colorChangeListenerList.add(changeListener);
} @Override
protected String title4PopupWindow() {
@Override return "Color";
protected String title4PopupWindow() { }
return "Color";
} /**
* 获取颜色
/** *
* 获取颜色 * @return 颜色
* @return 颜色 * Return the color.
* Return the color. */
*/ public Color getColor() {
public Color getColor() { return color;
return color; }
}
/**
/** * 获取颜色
* 获取颜色 *
* * @return 颜色
* @return 颜色 */
*/ public Color getNotNoneColor() {
public Color getNotNoneColor() { if (color == null) {
if (color == null) { setColor(Color.WHITE);
setColor(Color.WHITE); return Color.WHITE;
return Color.WHITE; }
} return color;
return color; }
}
/**
/** * Set the color.
* Set the color. *
* * @param color the new color.
* @param color */
* the new color. @Override
*/ public void setColor(Color color) {
@Override this.color = color;
public void setColor(Color color) {
this.color = color; // fire color change.
if (!colorChangeListenerList.isEmpty()) {
// fire color change. ChangeEvent evt = new ChangeEvent(this);
if (!colorChangeListenerList.isEmpty()) {
ChangeEvent evt = new ChangeEvent(this); for (int i = 0; i < colorChangeListenerList.size(); i++) {
this.colorChangeListenerList.get(i).stateChanged(evt);
for (int i = 0; i < colorChangeListenerList.size(); i++) { }
this.colorChangeListenerList.get(i).stateChanged(evt); }
} ColorSelectConfigManager.getInstance().addToColorQueue(color);
} this.repaint();
ColorSelectConfigManager.getInstance().addToColorQueue(color); }
this.repaint();
} /**
* 设置颜色
/** *
* 设置颜色 * @param 颜色位置
* @param 颜色位置 */
*/ @Override
@Override public void colorSetted(ColorCell colorCell) {
public void colorSetted(ColorCell colorCell) { colorCell.repaint();
colorCell.repaint(); }
}
protected void doTransparent() {
protected void doTransparent() { setColor(null);
setColor(null); }
}
protected void customButtonPressed() { protected void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE); pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
} }
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if(isSupportTransparent){ if (isSupportTransparent) {
return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT); return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT);
} }
return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT); return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT);
} }
/** /**
* 更新最近使用颜色 * 更新最近使用颜色
* */
*/ public void updateUsedColor() {
public void updateUsedColor(){ usedColorPane.updateUsedColor();
usedColorPane.updateUsedColor(); }
}
} }

91
designer_base/src/com/fr/design/style/color/RecentUseColorPane.java

@ -1,55 +1,48 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
public class RecentUseColorPane extends BasicPane implements ColorSelectable{ import javax.swing.*;
import java.awt.*;
JColorChooser chooser;
public class RecentUseColorPane extends BasicPane implements ColorSelectable {
@Override
protected String title4PopupWindow() { private JColorChooser chooser;
return null;
} @Override
protected String title4PopupWindow() {
public RecentUseColorPane() { return null;
} }
public RecentUseColorPane(JColorChooser chooser) {
this.chooser = chooser; public RecentUseColorPane(JColorChooser chooser) {
this.chooser = chooser;
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); // center
this.add(centerPane, BorderLayout.CENTER); JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
// 最近使用 this.add(centerPane, BorderLayout.CENTER);
UsedColorPane pane = new UsedColorPane(2, 10, ColorSelectConfigManager.getInstance().getColors(),this); // 最近使用
centerPane.add(pane.getPane()); UsedColorPane pane = new UsedColorPane(2, 10, this);
} centerPane.add(pane.getPane());
}
/**
* 选中颜色 /**
* * 选中颜色
* @param 颜色 */
*/ @Override
@Override public void colorSetted(ColorCell color) {
public void colorSetted(ColorCell color) {
}
}
@Override
@Override public Color getColor() {
public Color getColor() { return null;
return null; }
}
@Override
@Override public void setColor(Color color) {
public void setColor(Color color) { chooser.getSelectionModel().setSelectedColor(color);
chooser.getSelectionModel().setSelectedColor(color); }
}
} }

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

@ -1,119 +1,112 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.SpecialUIButton; import com.fr.design.gui.ibutton.SpecialUIButton;
public class UsedColorPane extends BasicPane{ import javax.swing.*;
import java.awt.*;
public static final Color DEFAULT_COLOR = new Color(222,222,222);
public class UsedColorPane extends BasicPane {
// 最近使用面板列数
private int columns; // 默认显示颜色
// 最近使用面板行数 public static final Color DEFAULT_COLOR = new Color(222, 222, 222);
private int rows;
// 留白的单元格数量 // 最近使用面板列数
private int reserveCells; private int columns;
// 是否需要取色器按钮 // 最近使用面板行数
private boolean needPickColorButton; private int rows;
// 是否在取色时实时设定颜色 // 留白的单元格数量
private boolean setColorRealTime; private int reserveCells;
// 最近使用颜色 // 是否需要取色器按钮
private Object[] colors; private boolean needPickColorButton;
// 最近使用面板 // 是否在取色时实时设定颜色
private JPanel pane; private boolean setColorRealTime;
private ColorSelectable selectable; // 最近使用面板
private JPanel pane;
public JPanel getPane() {
return pane; private ColorSelectable selectable;
}
public JPanel getPane() {
public void setPane(JPanel pane) { return pane;
this.pane = pane; }
}
public void setPane(JPanel pane) {
public UsedColorPane(){ this.pane = pane;
}
}
/** /**
* 构造函数 * 构造函数
* *
* @param rows * @param rows
* @param columns * @param columns
* @param reserveCells 留白的单元格个数 * @param reserveCells 留白的单元格个数
* @param colors 最近使用的颜色 * @param colors 最近使用的颜色
* @param needPickColorButton 是否需要加上取色器按钮 * @param needPickColorButton 是否需要加上取色器按钮
* @param setColorRealTime 取色器是否实时设定颜色 * @param setColorRealTime 取色器是否实时设定颜色
*/ */
public UsedColorPane(int rows,int columns,int reserveCells, Object[] colors, ColorSelectable selectable, boolean needPickColorButton, boolean setColorRealTime){ public UsedColorPane(int rows, int columns, int reserveCells, ColorSelectable selectable, boolean needPickColorButton, boolean setColorRealTime) {
this.columns = columns; this.columns = columns;
this.rows = rows; this.rows = rows;
this.reserveCells = reserveCells; this.reserveCells = reserveCells;
this.colors = colors; this.selectable = selectable;
this.selectable = selectable; this.needPickColorButton = needPickColorButton;
this.needPickColorButton = needPickColorButton; this.setColorRealTime = setColorRealTime;
this.setColorRealTime = setColorRealTime; initialComponents();
initialComponents(); }
}
public UsedColorPane(int rows, int columns, ColorSelectable selectable) {
public UsedColorPane(int rows,int columns, Object[] colors,ColorSelectable selectable){ this(rows, columns, 0, selectable, false, false);
this(rows, columns, 0, colors, selectable, false, false); }
}
private void initialComponents() {
private void initialComponents(){ int total = columns * rows;
int total = columns * rows; JPanel panel = new JPanel();
JPanel panel = new JPanel(); panel.setLayout(new GridLayout(rows, columns, 1, 1));
panel.setLayout(new GridLayout(rows,columns, 1, 1)); panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); //最近使用颜色
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) {
// 取色按钮 // 取色按钮
SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime); SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime);
panel.add(pickColorButton); panel.add(pickColorButton);
i++; i++;
this.reserveCells += 1; this.reserveCells += 1;
} }
while (i < this.reserveCells) { while (i < this.reserveCells) {
ColorCell cc = new ColorCell(DEFAULT_COLOR, selectable); ColorCell cc = new ColorCell(DEFAULT_COLOR, selectable);
cc.setVisible(false); cc.setVisible(false);
panel.add(cc); panel.add(cc);
i++; i++;
} }
while (i < total) { while (i < total) {
Color color = i < size ? colors[size-1-i]: DEFAULT_COLOR; Color color = i < 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++;
} }
this.pane = panel; this.pane = panel;
} }
/** /**
* 更新最近使用颜色 * 更新最近使用颜色
* */
*/ public void updateUsedColor() {
public void updateUsedColor(){ int total = columns * rows;
int total = columns * rows; Color[] colors = ColorSelectConfigManager.getInstance().getColors();
Color[] colors = ColorSelectConfigManager.getInstance().getColors(); 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 < size ? colors[size-1-i]: DEFAULT_COLOR; cell.setColor(color == null ? DEFAULT_COLOR : color);
cell.setColor(color == null ? DEFAULT_COLOR : color); }
} }
}
@Override
@Override protected String title4PopupWindow() {
protected String title4PopupWindow() { return null;
return null; }
}
} }

4
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;
@ -127,7 +127,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();

2
designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkPane.java

@ -95,6 +95,8 @@ public class FormHyperlinkPane extends BasicBeanPane<FormHyperlinkProvider> {
parameterList.toArray(parameters); parameterList.toArray(parameters);
formHyperlink.setParameters(parameters); formHyperlink.setParameters(parameters);
} else {
formHyperlink.setParameters(null);
} }
} }

29
designer_chart/src/com/fr/design/mainframe/chart/gui/data/TableDataPane.java

@ -25,6 +25,10 @@ public class TableDataPane extends FurtherBasicBeanPane<ChartCollection>{
private ChartDataPane parent; private ChartDataPane parent;
protected AbstractTableDataContentPane getDataContentPane() {
return dataContentPane;
}
public TableDataPane(ChartDataPane parent) { public TableDataPane(ChartDataPane parent) {
this.parent = parent; this.parent = parent;
initDataPane(); initDataPane();
@ -103,15 +107,18 @@ public class TableDataPane extends FurtherBasicBeanPane<ChartCollection>{
* @param collection 图表属性的集合 * @param collection 图表属性的集合
*/ */
public void refreshContentPane(ChartCollection collection) { public void refreshContentPane(ChartCollection collection) {
refreshContentPane(getContentPane(collection.getSelectedChart().getPlot()));
}
protected void refreshContentPane(AbstractTableDataContentPane contentPane) {
if(dataContentPane != null) { if(dataContentPane != null) {
remove(dataContentPane); remove(dataContentPane);
} }
dataContentPane = getContentPane(collection.getSelectedChart().getPlot()); dataContentPane = contentPane;
if(dataContentPane != null) { if(dataContentPane != null) {
add(dataContentPane, BorderLayout.CENTER); add(dataContentPane, BorderLayout.CENTER);
} }
} }
/** /**
* 更新界面属性 * 更新界面属性
*/ */
@ -120,17 +127,21 @@ public class TableDataPane extends FurtherBasicBeanPane<ChartCollection>{
return; return;
} }
TableDataDefinition data = (TableDataDefinition)collection.getSelectedChart().getFilterDefinition(); TableDataDefinition data = (TableDataDefinition)collection.getSelectedChart().getFilterDefinition();
populateDSName(data);
if(dataContentPane != null) {
dataContentPane.populateBean(collection);
}
}
protected void populateDSName(TableDataDefinition dataDefinition){
TableData tableData = null; TableData tableData = null;
if(data != null) { if(dataDefinition != null) {
tableData = data.getTableData(); tableData = dataDefinition.getTableData();
} }
onSelectTableData(); onSelectTableData();
checkBoxUse(); checkBoxUse();
tableDataPane.populateBean(tableData); tableDataPane.populateBean(tableData);
if(dataContentPane != null) {
dataContentPane.populateBean(collection);
}
} }
/** /**
@ -141,6 +152,10 @@ public class TableDataPane extends FurtherBasicBeanPane<ChartCollection>{
dataContentPane.updateBean(collection); dataContentPane.updateBean(collection);
} }
TopDefinition dataDefinition = (TopDefinition)collection.getSelectedChart().getFilterDefinition(); TopDefinition dataDefinition = (TopDefinition)collection.getSelectedChart().getFilterDefinition();
updateDSName(dataDefinition);
}
protected void updateDSName(TopDefinition dataDefinition) {
if(dataDefinition instanceof TableDataDefinition) { if(dataDefinition instanceof TableDataDefinition) {
TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper(); TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper();
if (dataDefinition != null && tableDataWrapper != null){ if (dataDefinition != null && tableDataWrapper != null){

79
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -1,7 +1,5 @@
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
import java.awt.*;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
@ -9,13 +7,14 @@ import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.BoundsGroupModel; import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import java.awt.*;
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
//是不是添加到父容器上 //是不是添加到父容器上
private boolean isAdd2ParentLayout = false; private boolean isAdd2ParentLayout = false;
@ -74,48 +73,39 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null){ if(topLayout != null){
if (topLayout.isEditable()){ if (topLayout.isEditable()){
return topLayoutAccept(creator, x, y, topLayout); return topLayoutAccept(creator, x, y);
} }
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局 //绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false; return false;
} else {
return acceptWidget(x, y);
} }
else { } else {
return acceptWidget(creator, x, y);
}
}
else{
FRLogger.getLogger().error("top layout is null!"); FRLogger.getLogger().error("top layout is null!");
} }
return false; return false;
} }
//toplayout假如可以编辑的话就往里面添加组件 //topLayout假如可以编辑的话就往里面添加组件
private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) { private boolean topLayoutAccept(XCreator creator, int x, int y) {
//判断有没有和当前控件重叠 //允许组件重叠,可以不判断有没有和当前控件重叠
//先计算当前控件的位置 //先计算当前控件的位置
int creatorX, creatorY; int creatorX, creatorY;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
creatorX = creatorRectangle.x; creatorX = creatorRectangle.x;
creatorY = creatorRectangle.y; creatorY = creatorRectangle.y;
} else { } else {
//这边计算得到的组件其实位置是正确的,
//因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的,
// 例如高度为21,那么就是+10-10;
// 高度为20,那么就是+10-10; 没区别
int w = creator.getWidth() / 2; int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2; int h = creator.getHeight() / 2;
creatorX = x - w; creatorX = x - w;
creatorY = y - h; creatorY = y - h;
}
//再判断和布局中其他控件重叠
Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight());
WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData();
for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) {
BoundsWidget temp = (BoundsWidget) wAbsoluteLayout.getWidget(i);
Rectangle rectangle = temp.getBounds();
if (curRec.intersects(rectangle)){
return false;
}
} }
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
return false; return false;
@ -168,16 +158,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
return !ComparatorUtils.equals(trisectAreaDirect, 0); return !ComparatorUtils.equals(trisectAreaDirect, 0);
} }
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围 //当前绝对布局不可编辑,就当成一个控件,组件添加在周围
private boolean acceptWidget(XCreator creator, int x, int y){ private boolean acceptWidget(int x, int y) {
isFindRelatedComps = false; isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y); Component comp = container.getComponentAt(x, y);
boolean isMatchEdge = false; //如果当前处于边缘地带, 那么就把他贴到父容器上
//如果当前处于边缘地带, 那么就把他贴到父容器上 XLayoutContainer parent = container.findNearestFit();
XLayoutContainer parent = container.findNearestFit(); container = parent != null ? parent : container;
container = parent != null ? parent : container; isAdd2ParentLayout = true;
isAdd2ParentLayout = true;
int componentHeight = comp.getHeight(); int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth(); int componentWidth = comp.getWidth();
@ -244,7 +233,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (creator.hasTitleStyle()) { if (creator.hasTitleStyle()) {
addParentCreator(creator); addParentCreator(creator);
} else { } else {
container.add(creator, creator.toData().getWidgetName()); container.add(creator, creator.toData().getWidgetName(),0);
} }
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator); layout.updateBoundsWidget(creator);
@ -255,7 +244,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
addParentCreator(creator); addParentCreator(creator);
} else { } else {
container.add(creator, creator.toData().getWidgetName()); container.add(creator, creator.toData().getWidgetName(),0);
} }
XWFitLayout layout = (XWFitLayout) container; XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget // 更新对应的BoundsWidget
@ -274,7 +263,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
private void addParentCreator(XCreator child) { private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight()); XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight());
container.add(parentPanel, child.toData().getWidgetName()); container.add(parentPanel, child.toData().getWidgetName(),0);
} }
/** /**
@ -325,17 +314,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
int height = creator.getHeight(); int height = creator.getHeight();
int width = creator.getWidth(); int width = creator.getWidth();
if (x < 0) { if (x < 0) {
width += x; x = container.getX();
x = 0;
} else if (x + creator.getWidth() > container.getWidth()) { } else if (x + creator.getWidth() > container.getWidth()) {
width = container.getWidth() - x; x = container.getWidth() - width;
} }
if (y < 0) { if (y < 0) {
height += y; y = container.getY();
y = 0;
} else if (y + creator.getHeight() > container.getHeight()) { } else if (y + creator.getHeight() > container.getHeight()) {
height = container.getHeight() - y; y = container.getHeight() - height;
} }
creator.setBounds(x, y, width, height); creator.setBounds(x, y, width, height);

81
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -3,12 +3,6 @@
*/ */
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
@ -22,14 +16,16 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutConstraints;
import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.JForm;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/** /**
* 自适应布局的容器适配器 * 自适应布局的容器适配器
@ -52,6 +48,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public void setEdit(boolean edit) { public void setEdit(boolean edit) {
isEdit = edit; isEdit = edit;
} }
/** /**
* 构造函数 * 构造函数
* *
@ -134,7 +131,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
isFindRelatedComps = false; isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y); Component comp = container.getComponentAt(x, y);
if (checkInterval(comp)) { if (comp == null || checkInterval(comp)) {
return false; return false;
} }
//如果当前处于边缘地带, 那么就把他贴到父容器上 //如果当前处于边缘地带, 那么就把他贴到父容器上
@ -269,25 +266,14 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
return super.isCrossPointArea(currentComp, x, y); return super.isCrossPointArea(currentComp, x, y);
} }
protected void initCompsList() {
super.initCompsList();
}
protected void clearCompsList() {
super.clearCompsList();
}
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout){ protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) {
return mainLayout.getBounds(); return mainLayout.getBounds();
} }
private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) { private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) {
// 参数界面高度对纵坐标产生的影响 // zhouping: REPORT-2334 表单tab布局中图表放大缩小会明显
JForm jform = (JForm) (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); // 这边不需要单独处理参数面板高度了,下面的方法中获取的是XWCardMainBorderLayout相对坐标
if (jform.getFormDesign().getParaComponent() != null) {
backupBound.y -= jform.getFormDesign().getParaHeight();
}
Rectangle rec = getLayoutBound(mainLayout); Rectangle rec = getLayoutBound(mainLayout);
// XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响 // XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响
// 减掉之后可以按照它原来的逻辑执行 // 减掉之后可以按照它原来的逻辑执行
@ -353,13 +339,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* 拖拽控件边框后根据控件的大小尺寸进行相关组件的调整 * 拖拽控件边框后根据控件的大小尺寸进行相关组件的调整
* *
* @param backupBound 边界备份 * @param backupBound 边界备份
* @param bounds 组件边界 * @param bounds 组件边界
* @param xCreator 组件 * @param xCreator 组件
* @param row 选中的行 * @param row 选中的行
* @param difference 偏移量 * @param difference 偏移量
*/ */
public void calculateBounds(Rectangle backupBound, Rectangle bounds, XCreator xCreator, int row, int difference) { public void calculateBounds(Rectangle backupBound, Rectangle bounds, XCreator xCreator, int row, int difference) {
Rectangle rc = new Rectangle(0,0,0,0); Rectangle rc = new Rectangle(0, 0, 0, 0);
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator);
if (parent != null) { if (parent != null) {
Rectangle rec = ComponentUtils.getRelativeBounds(parent); Rectangle rec = ComponentUtils.getRelativeBounds(parent);
@ -370,17 +356,17 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
//处理左右延伸 //处理左右延伸
switch (row) { switch (row) {
case 0: case 0:
if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight() +rc.x) { if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight() + rc.x) {
x += difference; x += difference;
} }
break; break;
case 1: case 1:
if(backupBound.y + backupBound.height == container.getHeight() - margin.getBottom() +rc.y){ if (backupBound.y + backupBound.height == container.getHeight() - margin.getBottom() + rc.y) {
y += difference; y += difference;
} }
break; break;
} }
bounds.setLocation(x,y); bounds.setLocation(x, y);
xCreator.setBackupBound(backupBound); xCreator.setBackupBound(backupBound);
xCreator.setBounds(bounds); xCreator.setBounds(bounds);
this.fix(xCreator); this.fix(xCreator);
@ -424,7 +410,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
// 根据需要依附的位置调整拖拽的坐标值 // 根据需要依附的位置调整拖拽的坐标值
private int adjustCoordinateByDependingLine(int coordinate, int[] coordinates) { private int adjustCoordinateByDependingLine(int coordinate, int[] coordinates) {
if(!isEdit) { if (!isEdit) {
for (int i = 0; i < coordinates.length; i++) { for (int i = 0; i < coordinates.length; i++) {
if (coordinate == coordinates[i]) { if (coordinate == coordinates[i]) {
continue; continue;
@ -440,7 +426,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
// 根据需要依附的位置调整拖拽的距离 // 根据需要依附的位置调整拖拽的距离
private int adjustDiffByDependingLine(int coordinate, int[] coordinates, int diff) { private int adjustDiffByDependingLine(int coordinate, int[] coordinates, int diff) {
if(!isEdit) { if (!isEdit) {
for (int i = 0; i < coordinates.length; i++) { for (int i = 0; i < coordinates.length; i++) {
if (coordinate + diff > coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) { if (coordinate + diff > coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) {
diff = coordinates[i] - coordinate; diff = coordinates[i] - coordinate;
@ -558,8 +544,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minWidth - getMinWidth(leftComps)); difference = Math.max(difference, minWidth - getMinWidth(leftComps));
} }
//重新计算左右两侧组件size、point //重新计算左右两侧组件size、point
if (CalculateLefttRelatComponent(difference)) { if (calculateLefttRelatComponent(difference)) {
CalculateRightRelatComponent(objx + difference, -difference); calculateRightRelatComponent(objx + difference, -difference);
} }
} }
@ -674,10 +660,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minHeight - getMinHeight(upComps)); difference = Math.max(difference, minHeight - getMinHeight(upComps));
} }
//重新计算上下两侧组件size、point //重新计算上下两侧组件size、point
if (CalculateUpRelatComponent(difference)) { if (calculateUpRelatComponent(difference)) {
CalculateDownRelatComponent(objY + difference, -difference); calculateDownRelatComponent(objY + difference, -difference);
} }
;
} }
/** /**
@ -757,13 +742,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
int height = creatorHeight; int height = creatorHeight;
calculateRelatedComponent(x, y, width, height); calculateRelatedComponent(x, y, width, height);
if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) { if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) {
CalculateRightRelatComponent(x, width + actualVal); calculateRightRelatComponent(x, width + actualVal);
} else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) { } else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) {
CalculateLefttRelatComponent(width + actualVal); calculateLefttRelatComponent(width + actualVal);
} else if (!downComps.isEmpty() && getAllWidth(downComps) == width) { } else if (!downComps.isEmpty() && getAllWidth(downComps) == width) {
CalculateDownRelatComponent(y, height + actualVal); calculateDownRelatComponent(y, height + actualVal);
} else if (!upComps.isEmpty() && getAllWidth(upComps) == width) { } else if (!upComps.isEmpty() && getAllWidth(upComps) == width) {
CalculateUpRelatComponent(height + actualVal); calculateUpRelatComponent(height + actualVal);
} else { } else {
// 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理 // 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理
calculateNoRelatedComponent(x, y, width, height); calculateNoRelatedComponent(x, y, width, height);
@ -1026,7 +1011,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
setAdjustedSize(tabLayout, offset, isHor); setAdjustedSize(tabLayout, offset, isHor);
for (int m = 0; m < tabLayout.getComponentCount(); m++) { for (int m = 0; m < tabLayout.getComponentCount(); m++) {
XCreator childCreator = tabLayout.getXCreator(m); XCreator childCreator = tabLayout.getXCreator(m);
BoundsWidget wgt = (BoundsWidget) tabLayout.toData().getBoundsWidget(childCreator.toData()); WAbsoluteLayout.BoundsWidget wgt = (WAbsoluteLayout.BoundsWidget) tabLayout.toData().getBoundsWidget(childCreator.toData());
wgt.setBounds(tabLayout.getComponent(m).getBounds()); wgt.setBounds(tabLayout.getComponent(m).getBounds());
} }
adjustCreatorsSize(percent, tabLayout, isHor); adjustCreatorsSize(percent, tabLayout, isHor);
@ -1069,7 +1054,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* @param objX 调整后的坐标x * @param objX 调整后的坐标x
* @param objWidth 调整后的宽度 * @param objWidth 调整后的宽度
*/ */
protected void CalculateRightRelatComponent(int objX, int objWidth) { protected void calculateRightRelatComponent(int objX, int objWidth) {
int count = rightComps.size(); int count = rightComps.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) rightComps.get(i); XCreator creator = (XCreator) rightComps.get(i);
@ -1109,7 +1094,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸控件左边框时 调整左侧的组件位置大小 * 删除或拉伸控件左边框时 调整左侧的组件位置大小
*/ */
protected boolean CalculateLefttRelatComponent(int objWidth) { protected boolean calculateLefttRelatComponent(int objWidth) {
if (isBeyondAdjustWidthScope(objWidth)) { if (isBeyondAdjustWidthScope(objWidth)) {
return false; return false;
} }
@ -1127,7 +1112,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸下边框 调整下方的组件位置大小 * 删除或拉伸下边框 调整下方的组件位置大小
*/ */
protected void CalculateDownRelatComponent(int objY, int objHeight) { protected void calculateDownRelatComponent(int objY, int objHeight) {
int count = downComps.size(); int count = downComps.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) downComps.get(i); XCreator creator = (XCreator) downComps.get(i);
@ -1167,7 +1152,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸上边框 调整上方的组件位置大小 * 删除或拉伸上边框 调整上方的组件位置大小
*/ */
protected boolean CalculateUpRelatComponent(int objHeight) { protected boolean calculateUpRelatComponent(int objHeight) {
if (isBeyondAdjustHeightScope(objHeight)) { if (isBeyondAdjustHeightScope(objHeight)) {
return false; return false;
} }

217
designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java

@ -27,32 +27,30 @@ public abstract class AccessDirection implements Direction {
abstract int getCursor(); abstract int getCursor();
protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle current_bounds, FormDesigner designer, protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer,
Rectangle oldbounds); Rectangle oldBounds);
protected int[] sorption(int x, int y,Rectangle current_bounds, FormDesigner designer) { protected int[] sorption(int x, int y, Rectangle currentBounds, FormDesigner designer) {
// 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理 // 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理
if (!designer.hasWAbsoluteLayout()) { if (!designer.hasWAbsoluteLayout()) {
designer.getStateModel().setEquidistantLine(null); designer.getStateModel().setEquidistantLine(null);
designer.getStateModel().setXAbsorptionline(null); designer.getStateModel().setXAbsorptionline(null);
designer.getStateModel().setYAbsorptionline(null); designer.getStateModel().setYAbsorptionline(null);
return new int[] { x, y }; return new int[]{x, y};
} else { } else {
int posy = current_bounds.y; Point relativePoint = getRelativePoint(x, y, currentBounds, designer);
sorptionPoint(relativePoint, currentBounds, designer);
Point relativePoint = getRelativePoint(x, y, current_bounds,designer); return new int[]{relativePoint.x, relativePoint.y};
sorptionPoint(relativePoint,current_bounds, designer); }
return new int[] { relativePoint.x, relativePoint.y };
}
} }
protected Point getRelativePoint(int x, int y, Rectangle current_bounds,FormDesigner designer) { protected Point getRelativePoint(int x, int y, Rectangle currentBounds, FormDesigner designer) {
if (x < 0) { if (x < 0) {
x = 0; x = 0;
} else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) { } else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) {
x = designer.getRootComponent().getWidth(); x = designer.getRootComponent().getWidth();
} }
//参数面板可以无下限拉长 //参数面板可以无下限拉长
if (y < 0) { if (y < 0) {
y = 0; y = 0;
@ -63,112 +61,101 @@ public abstract class AccessDirection implements Direction {
return new Point(x, y); return new Point(x, y);
} }
protected void sorptionPoint(Point point, Rectangle current_bounds,FormDesigner designer) { protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) {
boolean findInX = current_bounds.getWidth() <= MoveUtils.SORPTION_UNIT ? true : false; boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT;
boolean findInY = current_bounds.getHeight() <= MoveUtils.SORPTION_UNIT ? true : false; boolean findInY = currentBounds.getHeight() <= MoveUtils.SORPTION_UNIT;
WAbsoluteLayout layout =getLayout(designer); WAbsoluteLayout layout = getLayout(designer);
FormSelection selection = designer.getSelectionModel().getSelection(); FormSelection selection = designer.getSelectionModel().getSelection();
boolean isWidgetsIntersect = false; for (int i = 0, count = layout.getWidgetCount(); i < count; i++) {
for (int i = 0, count = layout.getWidgetCount(); i < count; i++) { BoundsWidget temp = (BoundsWidget) layout.getWidget(i);
BoundsWidget temp = (BoundsWidget) layout.getWidget(i); if (!temp.isVisible() || selection.contains(temp.getWidget())) {
if (!temp.isVisible() || selection.contains(temp.getWidget())) { continue;
continue; }
} Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection);
Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection); if (!findInX) {
if (!findInX) { int x1 = bounds.x;
int x1 = bounds.x; if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) {
if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) { point.x = x1;
point.x = x1; findInX = true;
findInX = true; }
} int x2 = bounds.x + bounds.width;
int x2 = bounds.x + bounds.width; if (Math.abs(x2 - point.x) <= MoveUtils.SORPTION_UNIT) {
if (Math.abs(x2 - point.x) <= MoveUtils.SORPTION_UNIT) { point.x = x2;
point.x = x2; findInX = true;
findInX = true; }
} }
} if (!findInY) {
if (!findInY) { int y1 = bounds.y;
int y1 = bounds.y; if (Math.abs(y1 - point.y) <= MoveUtils.SORPTION_UNIT) {
if (Math.abs(y1 - point.y) <= MoveUtils.SORPTION_UNIT) { point.y = y1;
point.y = y1; findInY = true;
findInY = true; }
} int y2 = bounds.y + bounds.height;
int y2 = bounds.y + bounds.height; if (Math.abs(y2 - point.y) <= MoveUtils.SORPTION_UNIT) {
if (Math.abs(y2 - point.y) <= MoveUtils.SORPTION_UNIT) { point.y = y2;
point.y = y2; findInY = true;
findInY = true; }
}
} }
if (findInX && findInY) { if (findInX && findInY) {
break; break;
} }
if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)){ }
isWidgetsIntersect = true; setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point);
} }
}
processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect);
setDesignerStateModelProperties(designer, findInX, findInY, current_bounds, point);
}
private void setDesignerStateModelProperties (FormDesigner designer, boolean findInX, boolean findInY, Rectangle current_bounds, Point point) { private void setDesignerStateModelProperties(FormDesigner designer, boolean findInX, boolean findInY, Rectangle
designer.getStateModel().setXAbsorptionline(findInX && current_bounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null); currentBounds, Point point) {
designer.getStateModel().setYAbsorptionline(findInY && current_bounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null); designer.getStateModel().setXAbsorptionline(findInX && currentBounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null);
designer.getStateModel().setEquidistantLine(null); designer.getStateModel().setYAbsorptionline(findInY && currentBounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null);
} designer.getStateModel().setEquidistantLine(null);
}
private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection){ private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection) {
Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (parent == null) { if (parent == null) {
return relativeRec; return relativeRec;
} }
Rectangle rec = ComponentUtils.getRelativeBounds(parent); Rectangle rec = ComponentUtils.getRelativeBounds(parent);
relativeRec.x += rec.x; relativeRec.x += rec.x;
relativeRec.y += rec.y; relativeRec.y += rec.y;
return relativeRec; return relativeRec;
} }
private void processRectangleIntersects(FormDesigner designer, int x, int y, boolean isIntersects){
if(isIntersects){
if(designer.getLocationOnScreen() != null) {
MoveUtils.displayForbidWindow(x + designer.getLocationOnScreen().x, y + designer.getLocationOnScreen().y);
}
designer.setWidgetsIntersect(true);
}
else{
MoveUtils.hideForbidWindow();
designer.setWidgetsIntersect(false);
}
}
private WAbsoluteLayout getLayout(final FormDesigner designer){ private WAbsoluteLayout getLayout(final FormDesigner designer){
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(
designer.getTarget().getContainer()); designer.getTarget().getContainer());
WAbsoluteLayout layout; WAbsoluteLayout layout;
if (formLayoutContainer.acceptType(XWBorderLayout.class)){//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面 if (formLayoutContainer.acceptType(XWBorderLayout.class)) {//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent(); Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent();
if(container instanceof XWAbsoluteLayout){ if (container instanceof XWAbsoluteLayout) {
layout = ((XWAbsoluteLayout)container).toData(); layout = ((XWAbsoluteLayout) container).toData();
} } else {
else { layout = (WAbsoluteLayout) designer.getParaComponent().toData();
layout = (WAbsoluteLayout) designer.getParaComponent().toData(); }
} } else {
} else{
layout = (WAbsoluteLayout) designer.getTarget().getContainer(); layout = (WAbsoluteLayout) designer.getTarget().getContainer();
} }
return layout; return layout;
} }
/** /**
* 拖拽 * 拖拽
* @param dx 坐标x *
* @param dy 坐标y * @param dx 坐标x
* @param designer 设计界面 * @param dy 坐标y
*/ * @param designer 设计界面
public void drag(int dx, int dy, FormDesigner designer) { */
Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds()); public void drag(int dx, int dy, FormDesigner designer) {
Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds());
if (rec != null) {
designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer);
} else {
return;
}
//设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。 //设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。
if(rec.height == MINHEIGHT){ if(rec.height == MINHEIGHT){
ymin = rec.y; ymin = rec.y;
@ -191,10 +178,8 @@ public abstract class AccessDirection implements Direction {
rec.width = MINWIDTH; rec.width = MINWIDTH;
rec.x = xmin; rec.x = xmin;
} }
if(rec != null) {
designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer); }
}
}
/** /**
* 更新鼠标指针形状 * 更新鼠标指针形状

59
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -136,19 +136,35 @@ public class SelectionModel {
if (designer.getClass().equals(FormDesigner.class)) { if (designer.getClass().equals(FormDesigner.class)) {
if (selection.getSelectedCreator() instanceof XWFitLayout) { if (selection.getSelectedCreator() instanceof XWFitLayout) {
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) {
Rectangle rec = selection.getRelativeBounds(); XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator();
//Tab布局 //tab布局编辑器内部左上角第一个坐标点
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), int leftUpX = container.toData().getMargin().getLeft() + 1;
clipboard, int leftUpY = container.toData().getMargin().getTop() + 1;
rec.x + rec.width / 2, //选中第一个坐标点坐在的组件
rec.y + DELTA_X_Y); selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY));
Rectangle rectangle = selection.getRelativeBounds();
if (hasSelectedPasteSource()) {
selectedPaste();
} else {
FormSelectionUtils.paste2Container(designer, container, clipboard,
rectangle.x + rectangle.width / 2,
rectangle.y + DELTA_X_Y);
}
} else { } else {
Rectangle rec = selection.getRelativeBounds(); //自适应布局编辑器内部左上角第一个坐标点
//自适应布局 int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1;
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1;
clipboard, //选中第一个坐标点坐在的组件
rec.x + rec.width / 2, selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY));
rec.y + DELTA_X_Y); Rectangle rectangle = selection.getRelativeBounds();
if (hasSelectedPasteSource()) {
selectedPaste();
} else {
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
clipboard,
rectangle.x + rectangle.width / 2,
rectangle.y + DELTA_X_Y);
}
} }
} else { } else {
//绝对布局 //绝对布局
@ -178,12 +194,23 @@ public class SelectionModel {
container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) {
//自适应布局 //自适应布局
Rectangle selectionRec = selection.getRelativeBounds(); Rectangle selectionRec = selection.getRelativeBounds();
//获取父容器位置,补充因参数面板高度导致的位置坐标计算偏移
Rectangle containerRec = ComponentUtils.getRelativeBounds(container); Rectangle containerRec = ComponentUtils.getRelativeBounds(container);
//计算自适应布局位置 int positionX, positionY;
int positionX = selectionRec.x - containerRec.x + selectionRec.width / 2;
int positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE); if (container.getClass().equals(XWTabFitLayout.class)) {
//tab内部粘贴不补充高度偏移
//且不计算参数面板造成的影响,因为在
//@see com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter#addBean中做了
positionX = selectionRec.x + selectionRec.width / 2;
positionY = (int) (selectionRec.y + selectionRec.height * OFFSET_RELATIVE);
} else {
//计算自适应布局位置
positionX = selectionRec.x - containerRec.x + selectionRec.width / 2;
positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE);
}
FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY); FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY);
} else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { } else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) {
//绝对布局 //绝对布局

152
designer_form/src/com/fr/design/designer/creator/XElementCase.java

@ -34,8 +34,8 @@ import java.beans.PropertyDescriptor;
import java.util.Set; import java.util.Set;
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{
private UILabel imageLable; private UILabel imageLable;
private CoverReportPane coverPanel; private CoverReportPane coverPanel;
private FormDesigner designer; private FormDesigner designer;
//缩略图 //缩略图
private BufferedImage thumbnailImage; private BufferedImage thumbnailImage;
@ -64,18 +64,18 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
} }
/** /**
* 是否支持设置标题 * 是否支持设置标题
* @return 是返回true * @return 是返回true
*/ */
public boolean hasTitleStyle() { public boolean hasTitleStyle() {
return true; return true;
} }
/** /**
* 返回组件属性值 * 返回组件属性值
* @return 返回组件属性值 * @return 返回组件属性值
* @throws IntrospectionException 异常 * @throws IntrospectionException 异常
*/ */
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{ CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{
@ -86,7 +86,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
@Override @Override
public void propertyChange() { public void propertyChange() {
makeVisible(toData().isVisible());} makeVisible(toData().isVisible());
}
}), }),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
WLayoutBorderStyleEditor.class).setI18NName( WLayoutBorderStyleEditor.class).setI18NName(
@ -97,12 +98,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
public void propertyChange() { public void propertyChange() {
initStyle(); initStyle();
} }
}), }),
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
.setI18NName(Inter.getLocText("FR-Layout_Padding")) .setI18NName(Inter.getLocText("FR-Layout_Padding"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("ToolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class) new CRPropertyDescriptor("toolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class)
.setI18NName(Inter.getLocText("Form-EC_toolbar")) .setI18NName(Inter.getLocText("Form-EC_toolbar"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
}; };
@ -149,30 +149,30 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return "text_field_16.png"; return "text_field_16.png";
} }
/** /**
* 返回组件默认名 * 返回组件默认名
* @return 组件类名(小写) * @return 组件类名(小写)
*/ */
public String createDefaultName() { public String createDefaultName() {
return "report"; return "report";
} }
@Override @Override
protected JComponent initEditor() { protected JComponent initEditor() {
if (editor == null) { if (editor == null) {
setBorder(DEFALUTBORDER); setBorder(DEFALUTBORDER);
editor = new JPanel(); editor = new JPanel();
editor.setBackground(null); editor.setBackground(null);
editor.setLayout(null); editor.setLayout(null);
imageLable = initImageBackground(); imageLable = initImageBackground();
coverPanel = new CoverReportPane(); coverPanel = new CoverReportPane();
coverPanel.setPreferredSize(imageLable.getPreferredSize()); coverPanel.setPreferredSize(imageLable.getPreferredSize());
coverPanel.setBounds(imageLable.getBounds()); coverPanel.setBounds(imageLable.getBounds());
editor.add(coverPanel); editor.add(coverPanel);
coverPanel.setVisible(false); coverPanel.setVisible(false);
editor.add(imageLable); editor.add(imageLable);
} }
return editor; return editor;
} }
@ -185,7 +185,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
BufferedImage image = getThumbnailImage(); BufferedImage image = getThumbnailImage();
setLabelBackground(image, imageLable); setLabelBackground(image, imageLable);
return imageLable; return imageLable;
} }
/** /**
@ -194,16 +194,16 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private void setLabelBackground(Image image, UILabel imageLable){ private void setLabelBackground(Image image, UILabel imageLable){
ImageIcon icon = new ImageIcon(image); ImageIcon icon = new ImageIcon(image);
imageLable.setIcon(icon); imageLable.setIcon(icon);
imageLable.setOpaque(true); imageLable.setOpaque(true);
imageLable.setLayout(null); imageLable.setLayout(null);
imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
} }
/** /**
* 是否展现覆盖的pane * 是否展现覆盖的pane
* @param display 是否 * @param display 是否
*/ */
public void displayCoverPane(boolean display){ public void displayCoverPane(boolean display){
coverPanel.setVisible(display); coverPanel.setVisible(display);
coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight()); coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight());
editor.repaint(); editor.repaint();
@ -216,41 +216,41 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
coverPanel.destroyHelpDialog(); coverPanel.destroyHelpDialog();
} }
public JComponent getCoverPane(){ public JComponent getCoverPane(){
return coverPanel; return coverPanel;
} }
/** /**
* 初始化大小 * 初始化大小
* @return 尺寸 * @return 尺寸
*/ */
public Dimension initEditorSize() { public Dimension initEditorSize() {
return BORDER_PREFERRED_SIZE; return BORDER_PREFERRED_SIZE;
} }
/** /**
* 是否是报表块 * 是否是报表块
* @return * @return
*/ */
public boolean isReport() { public boolean isReport() {
return true; return true;
} }
/** /**
* 该组件是否可以拖入参数面板 * 该组件是否可以拖入参数面板
* @return 是则返回true * @return 是则返回true
*/ */
public boolean canEnterIntoParaPane(){ public boolean canEnterIntoParaPane(){
return false; return false;
} }
/** /**
* 返回报表块对应的widget * 返回报表块对应的widget
* @return 返回ElementCaseEditor * @return 返回ElementCaseEditor
*/ */
public ElementCaseEditor toData() { public ElementCaseEditor toData() {
return ((ElementCaseEditor) data); return ((ElementCaseEditor) data);
} }
public FormElementCaseProvider getElementCase() { public FormElementCaseProvider getElementCase() {
return toData().getElementCase(); return toData().getElementCase();
@ -301,14 +301,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
} }
private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){ private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
if (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR){ if (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR){
FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e); FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e);
//切换设计器 //切换设计器
designer.switchTab(component); designer.switchTab(component);
} }
} }
@Override @Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {

924
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -3,14 +3,6 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.HashMap;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
@ -20,345 +12,369 @@ import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Connector; import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen; import com.fr.general.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.HashMap;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
*/ */
public class XWAbsoluteLayout extends XLayoutContainer { public class XWAbsoluteLayout extends XLayoutContainer {
private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24; private static final int EDIT_BTN_HEIGHT = 24;
private int minWidth = WLayout.MIN_WIDTH; private int minWidth = WLayout.MIN_WIDTH;
private int minHeight = WLayout.MIN_HEIGHT; private int minHeight = WLayout.MIN_HEIGHT;
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0; protected double containerPercent = 1.0;
private HashMap<Connector,XConnector> xConnectorMap; private HashMap<Connector, XConnector> xConnectorMap;
public XWAbsoluteLayout() { public XWAbsoluteLayout() {
this(new WAbsoluteLayout(),new Dimension()); this(new WAbsoluteLayout(), new Dimension());
} }
public XWAbsoluteLayout(WAbsoluteLayout widget) { public XWAbsoluteLayout(WAbsoluteLayout widget) {
this(widget,new Dimension()); this(widget, new Dimension());
} }
public XWAbsoluteLayout(WAbsoluteLayout widget, Dimension initSize) { public XWAbsoluteLayout(WAbsoluteLayout widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
this.xConnectorMap = new HashMap<Connector,XConnector>(); this.xConnectorMap = new HashMap<Connector, XConnector>();
Connector connector; Connector connector;
for (int i = 0; i < widget.connectorCount(); i++) { for (int i = 0; i < widget.connectorCount(); i++) {
connector = widget.getConnectorIndex(i); connector = widget.getConnectorIndex(i);
xConnectorMap.put(connector, new XConnector(connector, this)); xConnectorMap.put(connector, new XConnector(connector, this));
} }
initPercent(widget); initPercent(widget);
} }
/** /**
* 初始化时默认的组件大小 * 初始化时默认的组件大小
* *
* @return 默认Dimension * @return 默认Dimension
*/ */
@Override @Override
public Dimension initEditorSize() { public Dimension initEditorSize() {
return new Dimension(500, 300); return new Dimension(500, 300);
} }
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90% //根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
private void initPercent(WAbsoluteLayout widget){ private void initPercent(WAbsoluteLayout widget) {
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getByDimension(scrnsize).getValue(); double screenValue = FRScreen.getByDimension(scrnsize).getValue();
if(screenValue != FormArea.DEFAULT_SLIDER){ if (screenValue != FormArea.DEFAULT_SLIDER) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
} }
} }
/** /**
* 返回容器大小的百分比 * 返回容器大小的百分比
* @return the containerPercent *
*/ * @return the containerPercent
public double getContainerPercent() { */
return containerPercent; public double getContainerPercent() {
} return containerPercent;
}
/**
* 设置容器大小的百分比 /**
* @param containerPercent the containerPercent to set * 设置容器大小的百分比
*/ *
public void setContainerPercent(double containerPercent) { * @param containerPercent the containerPercent to set
this.containerPercent = containerPercent; */
minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH*containerPercent); public void setContainerPercent(double containerPercent) {
minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT*containerPercent); this.containerPercent = containerPercent;
} minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH * containerPercent);
minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT * containerPercent);
/** }
* 返回界面处根据百分比调整后的最小宽度
* @return 最小宽度 /**
*/ * 返回界面处根据百分比调整后的最小宽度
public int getActualMinWidth() { *
return this.minWidth; * @return 最小宽度
} */
public int getActualMinWidth() {
/** return this.minWidth;
* 返回界面处根据百分比调整后的最小高度 }
* @return 最小高度
*/ /**
public int getActualMinHeight() { * 返回界面处根据百分比调整后的最小高度
return this.minHeight; *
} * @return 最小高度
*/
/** public int getActualMinHeight() {
* 返回界面处根据百分比调整后的间隔大小且为偶数 return this.minHeight;
* @return 间隔 }
*/
public int getAcualInterval() { /**
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数 * 返回界面处根据百分比调整后的间隔大小且为偶数
int interval = (int) (toData().getCompInterval()*containerPercent); *
int val = interval/2; * @return 间隔
return val*2; */
} public int getAcualInterval() {
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
/** int interval = (int) (toData().getCompInterval() * containerPercent);
* 界面容器大小不是默认的时处理控件的BoundsWidget且避免出现空隙 int val = interval / 2;
*/ return val * 2;
private Rectangle dealWidgetBound(Rectangle rec) { }
if (containerPercent == 1.0) {
return rec; /**
} * 界面容器大小不是默认的时处理控件的BoundsWidget且避免出现空隙
rec.x = (int) (rec.x/containerPercent); */
rec.y = (int) (rec.y/containerPercent); private Rectangle dealWidgetBound(Rectangle rec) {
rec.width = (int) (rec.width/containerPercent); if (containerPercent == 1.0) {
rec.height = (int) (rec.height/containerPercent); return rec;
return rec; }
} rec.x = (int) (rec.x / containerPercent);
rec.y = (int) (rec.y / containerPercent);
/** rec.width = (int) (rec.width / containerPercent);
* 新增删除拉伸后单个组件的BoundsWidget rec.height = (int) (rec.height / containerPercent);
*/ return rec;
public void updateBoundsWidget(XCreator xCreator) { }
WAbsoluteLayout layout = this.toData();
if (xCreator.hasTitleStyle()) { /**
xCreator = (XLayoutContainer)xCreator.getParent(); * 新增删除拉伸后单个组件的BoundsWidget
} */
if (xCreator.acceptType(XWAbsoluteLayout.class)){ public void updateBoundsWidget(XCreator xCreator) {
((XWAbsoluteLayout) xCreator).updateBoundsWidget(); WAbsoluteLayout layout = this.toData();
} if (xCreator.hasTitleStyle()) {
// 如果子组件时tab布局,则tab布局内部的组件的wiget也要更新,否则保存后重新打开大小不对 xCreator = (XLayoutContainer) xCreator.getParent();
ArrayList<?> childrenList = xCreator.getTargetChildrenList(); }
if(!childrenList.isEmpty()){ if (xCreator.acceptType(XWAbsoluteLayout.class)) {
for(int i=0; i<childrenList.size(); i++){ ((XWAbsoluteLayout) xCreator).updateBoundsWidget();
XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(i); }
tabLayout.updateBoundsWidget(); // 如果子组件时tab布局,则tab布局内部的组件的wiget也要更新,否则保存后重新打开大小不对
} ArrayList<?> childrenList = xCreator.getTargetChildrenList();
} if (!childrenList.isEmpty()) {
BoundsWidget boundsWidget = (BoundsWidget) layout.getBoundsWidget(xCreator.toData()); Rectangle rectangle = dealWidgetBound(xCreator.getBounds()); for (int i = 0; i < childrenList.size(); i++) {
} XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(i);
tabLayout.updateBoundsWidget();
private Rectangle calculateBound(Rectangle rec, double pw, double ph){ }
Rectangle calRec = new Rectangle(0,0,0,0); }
calRec.x = (int)(rec.x / pw); BoundsWidget boundsWidget = (BoundsWidget) layout.getBoundsWidget(xCreator.toData());
calRec.y = (int)(rec.y / ph); Rectangle rectangle = dealWidgetBound(xCreator.getBounds());
calRec.width = (int)(rec.width / pw); }
calRec.height = (int)(rec.height / ph);
return calRec; private Rectangle calculateBound(Rectangle rec, double pw, double ph) {
} Rectangle calRec = new Rectangle(0, 0, 0, 0);
calRec.x = (int) (rec.x / pw);
/** calRec.y = (int) (rec.y / ph);
* 新增删除拉伸后每个组件的BoundsWidget calRec.width = (int) (rec.width / pw);
*/ calRec.height = (int) (rec.height / ph);
public void updateBoundsWidget() { return calRec;
WAbsoluteLayout layout = this.toData(); }
Rectangle backupBound = this.getBackupBound();
Rectangle currentBound = this.getBounds(); /**
if (backupBound != null && layout.getCompState() == WAbsoluteLayout.STATE_FIT) { * 新增删除拉伸后每个组件的BoundsWidget
double percentW = ((double) backupBound.width / (double) currentBound.width); */
double percentH = ((double) backupBound.height / (double) currentBound.height); public void updateBoundsWidget() {
for (int index = 0, n = this.getComponentCount(); index < n; index++){ WAbsoluteLayout layout = this.toData();
XCreator creator = (XCreator) this.getComponent(index); Rectangle backupBound = this.getBackupBound();
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); Rectangle currentBound = this.getBounds();
// 用当前的显示大小计算后调正具体位置 if (backupBound != null && layout.getCompState() == WAbsoluteLayout.STATE_FIT) {
Rectangle wgtBound = creator.getBounds(); double percentW = ((double) backupBound.width / (double) currentBound.width);
Rectangle rec = calculateBound(wgtBound, percentW, percentH); double percentH = ((double) backupBound.height / (double) currentBound.height);
wgt.setBounds(rec); for (int index = 0, n = this.getComponentCount(); index < n; index++) {
creator.setBounds(rec); XCreator creator = (XCreator) this.getComponent(index);
//绝对布局嵌套,要更新内部的绝对布局 BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());
if (creator.acceptType(XWAbsoluteLayout.class)){ // 用当前的显示大小计算后调正具体位置
creator.setBackupBound(wgtBound); Rectangle wgtBound = creator.getBounds();
((XWAbsoluteLayout) creator).updateBoundsWidget(); Rectangle rec = calculateBound(wgtBound, percentW, percentH);
} wgt.setBounds(rec);
} creator.setBounds(rec);
} //绝对布局嵌套,要更新内部的绝对布局
} if (creator.acceptType(XWAbsoluteLayout.class)) {
creator.setBackupBound(wgtBound);
/** ((XWAbsoluteLayout) creator).updateBoundsWidget();
* 更新子组件的Bound }
* 这边主要用于绝对布局子组件在适应区域选项时 }
* 涉及到的不同分辨率下缩放 }
* @param minHeight 最小高度 }
*/
@Override /**
public void updateChildBound(int minHeight) { * 更新子组件的Bound
double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; * 这边主要用于绝对布局子组件在适应区域选项时
if (toData().getCompState() == 0 && prevContainerPercent != containerPercent) { * 涉及到的不同分辨率下缩放
for (int i = 0; i < this.getComponentCount(); i++) { *
XCreator creator = getXCreator(i); * @param minHeight 最小高度
Rectangle rec = new Rectangle(creator.getBounds()); */
rec.x = (int)(rec.x / prevContainerPercent * containerPercent); @Override
rec.y = (int)(rec.y / prevContainerPercent * containerPercent); public void updateChildBound(int minHeight) {
rec.height = (int)(rec.height / prevContainerPercent * containerPercent); double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER;
rec.width = (int)(rec.width / prevContainerPercent * containerPercent); if (toData().getCompState() == 0 && prevContainerPercent != containerPercent) {
BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData()); for (int i = 0; i < this.getComponentCount(); i++) {
wgt.setBounds(rec); XCreator creator = getXCreator(i);
creator.setBounds(rec); Rectangle rec = new Rectangle(creator.getBounds());
creator.updateChildBound(minHeight); rec.x = (int) (rec.x / prevContainerPercent * containerPercent);
} rec.y = (int) (rec.y / prevContainerPercent * containerPercent);
} rec.height = (int) (rec.height / prevContainerPercent * containerPercent);
toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize()); rec.width = (int) (rec.width / prevContainerPercent * containerPercent);
} BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData());
wgt.setBounds(rec);
/** creator.setBounds(rec);
* 增加对齐线 creator.updateChildBound(minHeight);
* @param connector 对齐线 }
*/ }
public void addConnector(Connector connector) { toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize());
xConnectorMap.put(connector, new XConnector(connector, this)); }
((WAbsoluteLayout) data).addConnector(connector);
} /**
* 增加对齐线
public XConnector getXConnector(Connector connector) { *
return xConnectorMap.get(connector); * @param connector 对齐线
} */
public void addConnector(Connector connector) {
/** xConnectorMap.put(connector, new XConnector(connector, this));
* 去除对齐线 ((WAbsoluteLayout) data).addConnector(connector);
* @param connector 对齐线 }
*/
public void removeConnector(Connector connector) { public XConnector getXConnector(Connector connector) {
((WAbsoluteLayout) data).removeConnector(connector); return xConnectorMap.get(connector);
xConnectorMap.remove(connector); }
}
/**
/** * 去除对齐线
* 返回对应的widget容器 *
* @return 返回WAbsoluteLayout * @param connector 对齐线
*/ */
@Override public void removeConnector(Connector connector) {
public WAbsoluteLayout toData() { ((WAbsoluteLayout) data).removeConnector(connector);
return (WAbsoluteLayout) data; xConnectorMap.remove(connector);
} }
@Override /**
protected String getIconName() { * 返回对应的widget容器
return "layout_absolute_new.png"; *
} * @return 返回WAbsoluteLayout
*/
/** @Override
* 返回默认的容器name public WAbsoluteLayout toData() {
* @return 返回绝对布局容器名 return (WAbsoluteLayout) data;
*/ }
@Override
public String createDefaultName() { @Override
return "absolute"; protected String getIconName() {
} return "layout_absolute_new.png";
}
@Override
protected void initLayoutManager() { /**
this.setLayout(new FRAbsoluteLayout()); * 返回默认的容器name
} *
* @return 返回绝对布局容器名
/** */
* 是否支持标题样式 @Override
* public String createDefaultName() {
* @return 默认false return "absolute";
*/ }
@Override
public boolean hasTitleStyle() { @Override
return false; protected void initLayoutManager() {
} this.setLayout(new FRAbsoluteLayout());
}
@Override
public void paintComponent(Graphics g) { /**
super.paintComponent(g); * 是否支持标题样式
WAbsoluteLayout layout = (WAbsoluteLayout) data; *
Connector[] connector = layout.getConnector(); * @return 默认false
for (int i = 0, size = connector.length; i < size; i++) { */
connector[i].draw(g); @Override
} public boolean hasTitleStyle() {
} return false;
}
/**
* 转换保存组件信息的wlayout为对应的container @Override
*/ public void paintComponent(Graphics g) {
@Override super.paintComponent(g);
public void convert() { WAbsoluteLayout layout = (WAbsoluteLayout) data;
isRefreshing = true; Connector[] connector = layout.getConnector();
WAbsoluteLayout abs = toData(); for (int i = 0, size = connector.length; i < size; i++) {
this.removeAll(); connector[i].draw(g);
for (int i = 0, count = abs.getWidgetCount(); i < count; i++) { }
BoundsWidget bw = (BoundsWidget)abs.getWidget(i); }
if (bw != null) {
Rectangle bounds = bw.getBounds(); /**
XWidgetCreator comp = (XWidgetCreator)XCreatorUtils.createXCreator(bw.getWidget()); * 转换保存组件信息的wlayout为对应的container
if (!comp.acceptType(XWParameterLayout.class)) { */
comp.setDirections(Direction.ALL); @Override
} public void convert() {
add(comp); isRefreshing = true;
comp.setBounds(bounds); WAbsoluteLayout abs = toData();
} this.removeAll();
} for (int i = 0, count = abs.getWidgetCount(); i < count; i++) {
isRefreshing = false; BoundsWidget bw = (BoundsWidget) abs.getWidget(i);
} if (bw != null) {
Rectangle bounds = bw.getBounds();
/** XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget());
* 当前组件zorder位置替换新的控件 if (!comp.acceptType(XWParameterLayout.class)) {
* @param widget 控件 comp.setDirections(Direction.ALL);
* @param oldcreator 旧组件 }
* @return 组件 add(comp);
*/ comp.setBounds(bounds);
@Override }
public XCreator replace(Widget widget, XCreator oldcreator) { }
int i = this.getComponentZOrder(oldcreator); isRefreshing = false;
if (i != -1) { }
this.toData().replace(new BoundsWidget(widget, oldcreator.getBounds()),
new BoundsWidget(oldcreator.toData(), oldcreator.getBounds())); /**
this.convert(); * 当前组件zorder位置替换新的控件
return (XCreator) this.getComponent(i); *
} * @param widget 控件
return null; * @param oldcreator 旧组件
} * @return 组件
*/
/** @Override
public XCreator replace(Widget widget, XCreator oldcreator) {
int i = this.getComponentZOrder(oldcreator);
if (i != -1) {
this.toData().replace(new BoundsWidget(widget, oldcreator.getBounds()),
new BoundsWidget(oldcreator.toData(), oldcreator.getBounds()));
this.convert();
return (XCreator) this.getComponent(i);
}
return null;
}
/**
* 组件增加 * 组件增加
*
* @param e 容器事件 * @param e 容器事件
*/ */
@Override @Override
public void componentAdded(ContainerEvent e) { public void componentAdded(ContainerEvent e) {
if (isRefreshing) { if (isRefreshing) {
return; return;
} }
XWidgetCreator creator = (XWidgetCreator) e.getChild(); XWidgetCreator creator = (XWidgetCreator) e.getChild();
WAbsoluteLayout wabs = this.toData(); WAbsoluteLayout wabs = this.toData();
if (!creator.acceptType(XWFitLayout.class)) { if (!creator.acceptType(XWFitLayout.class)) {
creator.setDirections(Direction.ALL); creator.setDirections(Direction.ALL);
} }
wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds())); wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds()));
} }
/** /**
* 在设计界面中有组件移除的时候需要通知WLayout容器重新paint * 在设计界面中有组件移除的时候需要通知WLayout容器重新paint
*
* @param e 容器事件 * @param e 容器事件
*/ */
@Override @Override
@ -372,128 +388,130 @@ public class XWAbsoluteLayout extends XLayoutContainer {
BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds()); BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds());
wlayout.removeWidget(bw); wlayout.removeWidget(bw);
} }
@Override @Override
public Dimension getMinimumSize() { public Dimension getMinimumSize() {
return toData().getMinDesignSize(); return toData().getMinDesignSize();
} }
@Override @Override
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
return new FRAbsoluteLayoutAdapter(this); return new FRAbsoluteLayoutAdapter(this);
} }
@Override @Override
public XLayoutContainer getTopLayout() { public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout(); XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){ if (xTopLayout != null && !xTopLayout.isEditable()) {
return xTopLayout; return xTopLayout;
} } else {
else{ return this;
return this; }
} }
}
/**
/** * 得到属性名
* 得到属性名 *
* @return 属性名 * @return 属性名
* @throws java.beans.IntrospectionException * @throws java.beans.IntrospectionException
*/ */
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[] { return new CRPropertyDescriptor[]{
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName( new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(
Inter.getLocText("FR-Designer_Form-Widget_Name")) Inter.getLocText("FR-Designer_Form-Widget_Name"))
}; };
} }
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !this.editable) { if (isMouseEnter && !this.editable) {
int x = 0; int x = 0;
int y = 0; int y = 0;
int w = getWidth(); int w = getWidth();
int h = getHeight(); int h = getHeight();
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
//画白色的编辑层 //画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE); g2d.setColor(Color.WHITE);
g2d.fillRect(x, y, w, h); g2d.fillRect(x, y, w, h);
//画编辑按钮所在框 //画编辑按钮所在框
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222)); g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标 //画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH);
g2d.drawImage( g2d.drawImage(
image, image,
(x + w / 2 - 23), (x + w / 2 - 23),
(y + h / 2 - image.getHeight() / 2), (y + h / 2 - image.getHeight() / 2),
image.getWidth(), image.getWidth(),
image.getHeight(), image.getHeight(),
null, null,
this this
); );
g2d.setColor(Color.BLACK); g2d.setColor(Color.BLACK);
//画编辑文字 //画编辑文字
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5);
} }
} }
/** /**
* 响应点击事件 * 响应点击事件
* *
* @param editingMouseListener 鼠标点击位置处理器 * @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件 * @param e 鼠标点击事件
*/ */
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2; boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2;
setEditable(isEditing); setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e); selectionModel.selectACreatorAtMouseEvent(e);
designer.repaint(); designer.repaint();
if (editingMouseListener.stopEditing()) { if (editingMouseListener.stopEditing()) {
if (this != designer.getRootComponent()) { if (this != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
} }
} }
} }
/** /**
* body大小手动调整的时候 * body大小手动调整的时候
* 按照比例调整组件的宽度 * 按照比例调整组件的宽度
* @param percent 比例 *
*/ * @param percent 比例
@Override */
public void adjustCompWidth(double percent) { @Override
for (int i = 0; i < getComponentCount(); i++) { public void adjustCompWidth(double percent) {
XCreator xCreator = (XCreator) getComponent(i); for (int i = 0; i < getComponentCount(); i++) {
Rectangle rectangle = xCreator.getBounds(); XCreator xCreator = (XCreator) getComponent(i);
xCreator.setBounds((int) (rectangle.x * percent), rectangle.y, (int) (rectangle.width * percent), rectangle.height); Rectangle rectangle = xCreator.getBounds();
BoundsWidget widget = (BoundsWidget) toData().getBoundsWidget(xCreator.toData()); xCreator.setBounds((int) (rectangle.x * percent), rectangle.y, (int) (rectangle.width * percent), rectangle.height);
widget.setBounds(xCreator.getBounds()); BoundsWidget widget = (BoundsWidget) toData().getBoundsWidget(xCreator.toData());
} widget.setBounds(xCreator.getBounds());
} }
}
/**
* body大小手动调整的时候 /**
* 按照比例调整组件的高度 * body大小手动调整的时候
* @param percent 比例 * 按照比例调整组件的高度
*/ *
@Override * @param percent 比例
public void adjustCompHeight(double percent) { */
for (int i = 0; i < getComponentCount(); i++) { @Override
XCreator xCreator = (XCreator) getComponent(i); public void adjustCompHeight(double percent) {
Rectangle rectangle = xCreator.getBounds(); for (int i = 0; i < getComponentCount(); i++) {
xCreator.setBounds(rectangle.x, (int) (rectangle.y * percent), rectangle.width, (int) (rectangle.height * percent)); XCreator xCreator = (XCreator) getComponent(i);
BoundsWidget widget = (BoundsWidget) toData().getBoundsWidget(xCreator.toData()); Rectangle rectangle = xCreator.getBounds();
widget.setBounds(xCreator.getBounds()); xCreator.setBounds(rectangle.x, (int) (rectangle.y * percent), rectangle.width, (int) (rectangle.height * percent));
} BoundsWidget widget = (BoundsWidget) toData().getBoundsWidget(xCreator.toData());
} widget.setBounds(xCreator.getBounds());
}
}
} }

2
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java

@ -14,7 +14,7 @@ public class TabMoveEndAction extends TabMoveAction {
public TabMoveEndAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { public TabMoveEndAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t, xCardSwitchButton); super(t, xCardSwitchButton);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_End")); this.setName(Inter.getLocText("FR-Designer-Move_Tab_End"));
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/rightright.png")); this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/tab/end.png"));
} }
//改变Tab的索引号 //改变Tab的索引号

2
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java

@ -14,7 +14,7 @@ public class TabMoveFirstAction extends TabMoveAction {
public TabMoveFirstAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { public TabMoveFirstAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t, xCardSwitchButton); super(t, xCardSwitchButton);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_First")); this.setName(Inter.getLocText("FR-Designer-Move_Tab_First"));
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/leftleft.png")); this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/tab/first.png"));
} }
@Override @Override

2
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java

@ -14,7 +14,7 @@ public class TabMoveNextAction extends TabMoveAction {
public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t, xCardSwitchButton); super(t, xCardSwitchButton);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next")); this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next"));
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/right.png")); this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/tab/next.png"));
} }
@Override @Override

2
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java

@ -14,7 +14,7 @@ public class TabMovePrevAction extends TabMoveAction {
public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t, xCardSwitchButton); super(t, xCardSwitchButton);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev")); this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev"));
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/left.png")); this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/tab/prev.png"));
} }
@Override @Override

10
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -3,10 +3,6 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -17,12 +13,18 @@ import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.general.Inter; import com.fr.general.Inter;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
/** /**
* card布局主体框架 * card布局主体框架
* *

17
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -1,21 +1,14 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.Component; import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.DropMode; import javax.swing.DropMode;
import javax.swing.JPopupMenu;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel; import javax.swing.tree.TreeSelectionModel;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.designer.treeview.ComponentTreeModel;
@ -92,9 +85,9 @@ public class ComponentTree extends JTree {
} }
} }
public void setAndScrollSelectionPath(TreePath treepath) { public void setAndScrollSelectionPath(TreePath[] treepath) {
setSelectionPath(treepath); setSelectionPaths(treepath);
scrollPathToVisible(treepath); scrollPathToVisible(treepath[0]);
} }
@ -112,7 +105,6 @@ public class ComponentTree extends JTree {
public TreePath[] getSelectedTreePath() { public TreePath[] getSelectedTreePath() {
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators(); XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators();
TreePath[] paths = new TreePath[creators.length]; TreePath[] paths = new TreePath[creators.length];
for (int i = 0; i < paths.length; i++) { for (int i = 0; i < paths.length; i++) {
paths[i] = buildTreePath(creators[i]); paths[i] = buildTreePath(creators[i]);
} }
@ -141,7 +133,7 @@ public class ComponentTree extends JTree {
paths[i] = buildTreePath(searchList.get(i)); paths[i] = buildTreePath(searchList.get(i));
} }
if(paths.length > 0) { if(paths.length > 0) {
setAndScrollSelectionPath(paths[0]); setAndScrollSelectionPath(paths);
} else { } else {
setSelectionPath(); setSelectionPath();
} }
@ -217,4 +209,5 @@ public class ComponentTree extends JTree {
Object[] components = path.toArray(); Object[] components = path.toArray();
return new TreePath(components); return new TreePath(components);
} }
} }

1
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -1018,7 +1018,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
} }
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
selectionModel.setSelectedCreators(selected); selectionModel.setSelectedCreators(selected);
TreePath path = e.getNewLeadSelectionPath(); TreePath path = e.getNewLeadSelectionPath();

55
designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -3,8 +3,10 @@ package com.fr.design.mainframe;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -83,14 +85,26 @@ public class FormSelectionUtils {
* 相对布局粘贴 * 相对布局粘贴
*/ */
private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) {
//@see FRTabFitLayoutAdapter
Rectangle tabContainerRect = ComponentUtils.getRelativeBounds(designer.getSelectionModel().getSelection()
.getSelectedCreator().getParent());
designer.getSelectionModel().getSelection().reset(); designer.getSelectionModel().getSelection().reset();
for (XCreator creator : clipboard.getSelectedCreators()) { for (XCreator creator : clipboard.getSelectedCreators()) {
try { try {
Widget copied = copyWidget(designer, creator); Widget copied = copyWidget(designer, creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (!adapter.accept(copiedCreator, x, y)) { if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste")); if (!adapter.accept(copiedCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
return; designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
} else {
if (!adapter.accept(copiedCreator, x, y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
} }
boolean addSuccess = adapter.addBean(copiedCreator, x, y); boolean addSuccess = adapter.addBean(copiedCreator, x, y);
if (addSuccess) { if (addSuccess) {
@ -118,29 +132,20 @@ public class FormSelectionUtils {
XLayoutContainer container = layoutAdapter.getContainer(); XLayoutContainer container = layoutAdapter.getContainer();
boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth(); boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth();
boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + yoffset > container.getHeight(); boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + yoffset > container.getHeight();
/*
* 组件原始位置位于布局的右下角 boolean isEdge = (x - DELAY_X_Y == container.getWidth() - copiedCreator.getWidth() / 2 - xoffset)
* 和布局右下边界线紧挨 && (y - DELAY_X_Y == container.getHeight() - copiedCreator.getHeight() / 2 - yoffset);
* 粘贴时组件在原始位置向左错开20像素
* x,y同时越界 y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y;
*/ if (xOut) {
if (xOut && yOut) { if (isEdge) {
//向左偏移 //向左偏移
x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset; x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset;
}
//紧贴下边界 //紧贴下边界
y = container.getHeight() - copiedCreator.getHeight() / 2 - yoffset; else {
return new Point(x, y); x = container.getWidth() - copiedCreator.getWidth() / 2 - xoffset;
} }
/*
* 组件原始位置与布局边界距离小于20像素下边界&右边界同时小于或者任意一个边界小于
* 则粘贴时距离小于20像素一侧直接贴近布局边界
* 距离大于20像素的一侧正常错开
* x,y中只有一个越界
*/
if ((xOut || yOut)) {
x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x;
y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y;
return new Point(x, y);
} }
} }
return new Point(x, y); return new Point(x, y);

7
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -259,8 +259,11 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
xCreator = designer.getRootComponent(); xCreator = designer.getRootComponent();
} }
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator);
//TODO container可能为空,引发空指针异常
return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class); boolean xCreatorAccept = xCreator.acceptType(XWParameterLayout.class);
boolean containerAccept = container!=null && container.acceptType(XWParameterLayout.class);
return xCreatorAccept || containerAccept;
} }
public void setEditingFormDesigner(BaseFormDesigner editor) { public void setEditingFormDesigner(BaseFormDesigner editor) {

7
designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

@ -65,7 +65,6 @@ public class UITreeComboBox extends JComboBox{
* @param o Object * @param o Object
*/ */
public void setSelectedItem(Object o){ public void setSelectedItem(Object o){
tree.setSelectionPath((TreePath)o);
getModel().setSelectedItem(o); getModel().setSelectedItem(o);
} }
@ -110,7 +109,7 @@ public class UITreeComboBox extends JComboBox{
int index, boolean isSelected, boolean cellHasFocus){ int index, boolean isSelected, boolean cellHasFocus){
if(tree != null && tree.getSelectedTreePath().length > 0){ if(tree != null && tree.getSelectedTreePath().length > 0){
TreePath path = tree.getSelectedTreePath()[0]; TreePath path = tree.getSelectedTreePath()[0];
tree.setAndScrollSelectionPath(path); tree.setAndScrollSelectionPath(tree.getSelectedTreePath());
Object node = path.getLastPathComponent(); Object node = path.getLastPathComponent();
value = node; value = node;
TreeCellRenderer r = tree.getCellRenderer(); TreeCellRenderer r = tree.getCellRenderer();
@ -132,7 +131,7 @@ public class UITreeComboBox extends JComboBox{
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
TreePath[] paths = tree.getSelectedTreePath(); TreePath[] paths = tree.getSelectedTreePath();
if (tree != null && paths.length > 0) { if (tree != null && paths.length > 0) {
tree.setAndScrollSelectionPath(paths[0]); tree.setAndScrollSelectionPath(paths);
setSelectedItem(paths[0]); setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath(); MenuSelectionManager.defaultManager().clearSelectedPath();
} }
@ -141,7 +140,7 @@ public class UITreeComboBox extends JComboBox{
tree.refreshUI(); tree.refreshUI();
TreePath[] paths = tree.getSelectedTreePath(); TreePath[] paths = tree.getSelectedTreePath();
if (tree != null && paths.length > 0) { if (tree != null && paths.length > 0) {
tree.setAndScrollSelectionPath(paths[0]); tree.setAndScrollSelectionPath(paths);
setSelectedItem(paths[0]); setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath(); MenuSelectionManager.defaultManager().clearSelectedPath();
} }

Loading…
Cancel
Save