Browse Source

Merge pull request #866 in BA/design from ~PAUL/design:master to master

* commit 'ee78c63f92afe56ea6112748becef733305a637b': (72 commits)
  国际化
  无JIRA任务,国际化翻译更新
  无JIRA任务,国际化翻译更新
  REPORT-2626 移除国际化文件中的无效key
  REPORT-2626 移除国际化文件中的无效key
  国际化修改 design部分第51-750个key的翻译修改 庄奇syoki 20170509
  Signed-off-by: unknown <李晓丽>
  国际化修改 design部分 1-50个 1901-结束部分key的翻译修改 20170508 庄奇syoki
  REPORT-2483 & REPORT-2484 国际化key转移;外文版的国际化文件和中文版不一致
  无JIRA任务  新release合并遗漏
  无任务,line separator
  REPORT-2537
  无任务,冲突调整,release到dev
  无JIRA任务,国际化,把release、master中的key合并到dev中
  无JIRA任务,解决冲突
  ct
  ct
  ct
  ct
  1
  ...
master
superman 7 years ago
parent
commit
099b4ec3ba
  1. 252
      designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java
  2. 831
      designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java
  3. 16
      designer/src/com/fr/design/widget/CellWidgetCardPane.java
  4. 345
      designer_base/src/com/fr/design/actions/server/ConnectionListAction.java
  5. 1099
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  6. 45
      designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java
  7. 266
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  8. 324
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java
  9. 155
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java
  10. 15
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionShowPane.java
  11. 52
      designer_base/src/com/fr/design/gui/style/BorderPane.java
  12. BIN
      designer_base/src/com/fr/design/images/control/tab/end.png
  13. BIN
      designer_base/src/com/fr/design/images/control/tab/end_not.png
  14. BIN
      designer_base/src/com/fr/design/images/control/tab/first.png
  15. BIN
      designer_base/src/com/fr/design/images/control/tab/first_not.png
  16. BIN
      designer_base/src/com/fr/design/images/control/tab/next.png
  17. BIN
      designer_base/src/com/fr/design/images/control/tab/next_not.png
  18. BIN
      designer_base/src/com/fr/design/images/control/tab/prev.png
  19. BIN
      designer_base/src/com/fr/design/images/control/tab/prev_not.png
  20. 1470
      designer_base/src/com/fr/design/locale/designer.properties
  21. 1483
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  22. 1998
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  23. 1477
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  24. 1428
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  25. 1464
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  26. 102
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  27. 15
      designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
  28. 342
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  29. 3
      designer_base/src/com/fr/design/style/color/ColorSelectConfigManager.java
  30. 190
      designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java
  31. 243
      designer_base/src/com/fr/design/style/color/ColorSelectPane.java
  32. 386
      designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
  33. 91
      designer_base/src/com/fr/design/style/color/RecentUseColorPane.java
  34. 219
      designer_base/src/com/fr/design/style/color/UsedColorPane.java
  35. 50
      designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java
  36. 22
      designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java
  37. 685
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  38. 68
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  39. 89
      designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
  40. 280
      designer_form/src/com/fr/design/designer/beans/models/AddingModel.java
  41. 950
      designer_form/src/com/fr/design/designer/beans/models/StateModel.java
  42. 190
      designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java
  43. 6
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  44. 924
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  45. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java
  46. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java
  47. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java
  48. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java
  49. 10
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  50. 17
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  51. 1
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  52. 5
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java
  53. 7
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java
  54. 2
      designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java
  55. 7
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

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

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

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

File diff suppressed because it is too large Load Diff

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;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* 选择数据连接的下拉框
*
* @editor zhou
* @since 2012-3-28下午3:02:30
*/
public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
private Class<? extends Connection> cls; // 所取的Connection都是cls及其子类
private java.util.List<String> nameList = new ArrayList<String>();
public ConnectionComboBoxPanel(Class<? extends Connection> cls) {
super();
this.cls = cls;
// alex:添加item change监听,当改变时改变DesignerEnvManager中的最近选中的数据连接
this.itemComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String selected = ConnectionComboBoxPanel.this.getSelectedItem();
if (StringUtils.isNotBlank(selected)) {
DesignerEnvManager.getEnvManager().setRecentSelectedConnection(selected);
}
}
});
refreshItems();
}
/*
* 刷新ComboBox.items
*/
protected java.util.Iterator<String> items() {
nameList = new ArrayList<String>();
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
java.util.Iterator<String> nameIt = mgr.getConnectionNameIterator();
while (nameIt.hasNext()) {
String conName = nameIt.next();
Connection connection = mgr.getConnection(conName);
filterConnection(connection, conName, nameList);
}
return nameList.iterator();
}
protected void filterConnection(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
}
public int getConnectionSize() {
return nameList.size();
}
public String getConnection(int i) {
return nameList.get(i);
}
/*
* 弹出对话框编辑Items
*/
protected void editItems() {
final ConnectionListPane connectionListPane = new ConnectionListPane();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
connectionListPane.populate(datasourceManager);
BasicDialog connectionListDialog = connectionListPane.showLargeWindow(
SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), new DialogActionAdapter() {
public void doOk() {
connectionListPane.update(datasourceManager);
// marks:保存数据
Env currentEnv = FRContext.getCurrentEnv();
try {
currentEnv.writeResource(datasourceManager);
} catch (Exception ex) {
FRContext.getLogger().error(ex.getMessage(), ex);
}
}
});
connectionListDialog.setVisible(true);
refreshItems();
}
public void populate(com.fr.data.impl.Connection connection) {
editButton.setEnabled(FRContext.getCurrentEnv().isRoot());
if (connection instanceof NameDatabaseConnection) {
this.setSelectedItem(((NameDatabaseConnection) connection).getName());
} else {
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));
}
}
}
package com.fr.design.data.datapane.connect;
import com.fr.base.FRContext;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.server.ConnectionListAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 选择数据连接的下拉框
*
* @editor zhou
* @since 2012-3-28下午3:02:30
*/
public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
private Class<? extends Connection> cls; // 所取的Connection都是cls及其子类
private List<String> nameList = new ArrayList<String>();
public ConnectionComboBoxPanel(Class<? extends Connection> cls) {
super();
this.cls = cls;
// alex:添加item change监听,当改变时改变DesignerEnvManager中的最近选中的数据连接
this.itemComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String selected = ConnectionComboBoxPanel.this.getSelectedItem();
if (StringUtils.isNotBlank(selected)) {
DesignerEnvManager.getEnvManager().setRecentSelectedConnection(selected);
}
}
});
refreshItems();
}
/*
* 刷新ComboBox.items
*/
protected Iterator<String> items() {
nameList = new ArrayList<String>();
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
Iterator<String> nameIt = mgr.getConnectionNameIterator();
while (nameIt.hasNext()) {
String conName = nameIt.next();
Connection connection = mgr.getConnection(conName);
filterConnection(connection, conName, nameList);
}
return nameList.iterator();
}
protected void filterConnection(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
}
public int getConnectionSize() {
return nameList.size();
}
public String getConnection(int i) {
return nameList.get(i);
}
/*
* 弹出对话框编辑Items
*/
protected void editItems() {
final ConnectionListPane connectionListPane = new ConnectionListPane();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
final DatasourceManager backupManager = datasourceManager.getBackUpManager();
connectionListPane.populate(datasourceManager);
final BasicDialog connectionListDialog = connectionListPane.showLargeWindow(
SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), null);
connectionListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
if (!connectionListPane.isNamePermitted()) {
connectionListDialog.setDoOKSucceed(false);
return;
}
if (!ConnectionListAction.doWithDatasourceManager(datasourceManager, backupManager, connectionListPane,
connectionListDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return;
}
// marks:保存数据
ConnectionListAction.writeFile(datasourceManager);
}
public void doCancel() {
datasourceManager.synchronizedWithServer();
}
});
connectionListDialog.setVisible(true);
refreshItems();
}
/**
* @param connection 数据库链接
*/
public void populate(Connection connection) {
editButton.setEnabled(FRContext.getCurrentEnv().isRoot());
if (connection instanceof NameDatabaseConnection) {
this.setSelectedItem(((NameDatabaseConnection) connection).getName());
} else {
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;
import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import java.util.*;
/**
* Connection List Pane.
*/
public class ConnectionListPane extends JListControlPane {
public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection");
private boolean isNamePermitted = true;
private HashMap<String, String> renameMap = new HashMap<String, String>();
public ConnectionListPane() {
renameMap.clear();
this.addEditingListner(new PropertyChangeAdapter() {
public void propertyChange() {
isNamePermitted = true;
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"};
String[] sign = new String[]{",", "!"};
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), Inter.getLocText(warning, sign));
setWarnigText(editingIndex);
isNamePermitted = false;
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeted(new List[]{Arrays.asList(allListNames)}, tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
String message = Inter.getLocText(new String[]{"Utils-has_been_existed", "DashBoard-ConnectionList", "Please_Rename"}, new String[]{"", tempName + ",", "!"});
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message);
setWarnigText(editingIndex);
}
if (isNamePermitted && !ComparatorUtils.equals(tempName, selectedName)) {
rename(selectedName, tempName);
}
}
});
}
protected void rename(String oldName, String newName) {
if (renameMap.containsKey(selectedName)) {
renameMap.remove(selectedName);
}
renameMap.put(selectedName, newName);
}
/**
* 名字是否允许
*
* @return /
*/
public boolean isNamePermitted() {
return isNamePermitted;
}
/**
* 检查按钮可用状态 Check button enabled.
*/
public void checkButtonEnabled() {
super.checkButtonEnabled();
isNamePermitted = !isContainsRename();
}
public HashMap<String, String> getRenameMap() {
return renameMap;
}
/**
* 创建菜单项
*
* @return 菜单项
*/
public NameableCreator[] createNameableCreators() {
NameableCreator[] creators = new NameableCreator[]{new NameObjectCreator(
"JDBC",
"/com/fr/design/images/data/source/jdbcTableData.png",
JDBCDatabaseConnection.class,
DatabaseConnectionPane.JDBC.class
), new NameObjectCreator(
"JNDI",
"/com/fr/design/images/data/source/jdbcTableData.png",
JNDIDatabaseConnection.class,
DatabaseConnectionPane.JNDI.class
)};
Set<ConnectionProvider> pluginCreators = ExtraDesignClassManager.getInstance().getArray(ConnectionProvider.XML_TAG);
for (ConnectionProvider provider : pluginCreators) {
NameObjectCreator creator = new NameObjectCreator(
provider.nameForConnection(),
provider.iconPathForConnection(),
provider.classForConnection(),
provider.appearanceForConnection()
);
creators = ArrayUtils.add(creators, creator);
}
return creators;
}
@Override
protected String title4PopupWindow() {
return TITLE_NAME;
}
/**
* Populate.
*
* @param datasourceManager the new datasourceManager.
*/
public void populate(DatasourceManagerProvider datasourceManager) {
Iterator<String> nameIt = datasourceManager.getConnectionNameIterator();
List<NameObject> nameObjectList = new ArrayList<NameObject>();
while (nameIt.hasNext()) {
String name = nameIt.next();
nameObjectList.add(new NameObject(name, datasourceManager.getConnection(name)));
}
this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
}
/**
* Update.
*/
public void update(DatasourceManagerProvider datasourceManager) {
// Nameable[]居然不能强转成NameObject[],一定要这么写...
Nameable[] res = this.update();
NameObject[] res_array = new NameObject[res.length];
java.util.Arrays.asList(res).toArray(res_array);
datasourceManager.clearAllConnection();
for (int i = 0; i < res_array.length; i++) {
NameObject nameObject = res_array[i];
datasourceManager.putConnection(nameObject.getName(), (Connection) nameObject.getObject());
}
}
package com.fr.design.data.datapane.connect;
import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import java.util.*;
/**
* Connection List Pane.
*/
public class ConnectionListPane extends JListControlPane implements ConnectionShowPane {
public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection");
private boolean isNamePermitted = true;
private HashMap<String, String> renameMap = new HashMap<String, String>();
public ConnectionListPane() {
renameMap.clear();
this.addEditingListner(new PropertyChangeAdapter() {
public void propertyChange() {
isNamePermitted = true;
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"};
String[] sign = new String[]{",", "!"};
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), Inter.getLocText(warning, sign));
setWarnigText(editingIndex);
isNamePermitted = false;
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeted(new List[]{Arrays.asList(allListNames)}, tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
String message = Inter.getLocText(new String[]{"Utils-has_been_existed", "DashBoard-ConnectionList", "Please_Rename"}, new String[]{"", tempName + ",", "!"});
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message);
setWarnigText(editingIndex);
}
if (isNamePermitted && !ComparatorUtils.equals(tempName, selectedName)) {
rename(selectedName, tempName);
}
}
});
}
protected void rename(String oldName, String newName) {
if (renameMap.containsKey(selectedName)) {
renameMap.remove(selectedName);
}
renameMap.put(selectedName, newName);
}
/**
* 名字是否允许
*
* @return /
*/
public boolean isNamePermitted() {
return isNamePermitted;
}
/**
* 检查按钮可用状态 Check button enabled.
*/
public void checkButtonEnabled() {
super.checkButtonEnabled();
isNamePermitted = !isContainsRename();
}
public HashMap<String, String> getRenameMap() {
return renameMap;
}
/**
* 创建菜单项
*
* @return 菜单项
*/
public NameableCreator[] createNameableCreators() {
NameableCreator[] creators = new NameableCreator[]{new NameObjectCreator(
"JDBC",
"/com/fr/design/images/data/source/jdbcTableData.png",
JDBCDatabaseConnection.class,
DatabaseConnectionPane.JDBC.class
), new NameObjectCreator(
"JNDI",
"/com/fr/design/images/data/source/jdbcTableData.png",
JNDIDatabaseConnection.class,
DatabaseConnectionPane.JNDI.class
)};
Set<ConnectionProvider> pluginCreators = ExtraDesignClassManager.getInstance().getArray(ConnectionProvider.XML_TAG);
for (ConnectionProvider provider : pluginCreators) {
NameObjectCreator creator = new NameObjectCreator(
provider.nameForConnection(),
provider.iconPathForConnection(),
provider.classForConnection(),
provider.appearanceForConnection()
);
creators = ArrayUtils.add(creators, creator);
}
return creators;
}
@Override
protected String title4PopupWindow() {
return TITLE_NAME;
}
/**
* Populate.
*
* @param datasourceManager the new datasourceManager.
*/
public void populate(DatasourceManagerProvider datasourceManager) {
Iterator<String> nameIt = datasourceManager.getConnectionNameIterator();
List<NameObject> nameObjectList = new ArrayList<NameObject>();
while (nameIt.hasNext()) {
String name = nameIt.next();
nameObjectList.add(new NameObject(name, datasourceManager.getConnection(name)));
}
this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
}
/**
* Update.
*/
public void update(DatasourceManagerProvider datasourceManager) {
// Nameable[]居然不能强转成NameObject[],一定要这么写...
Nameable[] res = this.update();
NameObject[] res_array = new NameObject[res.length];
java.util.Arrays.asList(res).toArray(res_array);
datasourceManager.clearAllConnection();
for (int i = 0; i < res_array.length; i++) {
NameObject nameObject = res_array[i];
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;
import com.fr.base.FRContext;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.HashMap;
public class ConnectionManagerPane extends LoadingBasicPane {
private UITextField connectionTextField;
private ConnectionListPane connectionListPane;
protected void initComponents(JPanel container) {
container.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel connectionPathPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
container.add(connectionPathPane, BorderLayout.NORTH);
connectionPathPane.setBorder(BorderFactory.createEmptyBorder(6, 2, 2, 2));
connectionPathPane.add(new UILabel(Inter.getLocText("FR-Designer_Save_Path") + ":"), BorderLayout.WEST);
this.connectionTextField = new UITextField();
connectionPathPane.add(connectionTextField, BorderLayout.CENTER);
this.connectionTextField.setEditable(false);
connectionListPane = new ConnectionListPane(){
protected void rename(String oldName,String newName) {
super.rename(oldName,newName);
renameConnection(oldName,newName);
}
};
container.add(connectionListPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Server-Define_Data_Connection");
}
public HashMap<String, String> getRenameMap() {
return connectionListPane.getRenameMap();
}
public void populate(DatasourceManagerProvider datasourceManager) {
this.connectionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME
+ File.separator + datasourceManager.fileName());
this.connectionListPane.populate(datasourceManager);
}
public void update(DatasourceManagerProvider datasourceManager) {
this.connectionListPane.update(datasourceManager);
}
/**
* 设置选中项
*
* @param index 选中项的序列号
*/
public void setSelectedIndex(int index) {
this.connectionListPane.setSelectedIndex(index);
}
/**
* 名字是否允许
* @return 允许返回true
*/
public boolean isNamePermitted() {
return connectionListPane.isNamePermitted();
}
package com.fr.design.data.datapane.connect;
import com.fr.base.FRContext;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.HashMap;
public class ConnectionManagerPane extends LoadingBasicPane implements ConnectionShowPane {
private UITextField connectionTextField;
private ConnectionListPane connectionListPane;
protected void initComponents(JPanel container) {
container.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel connectionPathPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
container.add(connectionPathPane, BorderLayout.NORTH);
connectionPathPane.setBorder(BorderFactory.createEmptyBorder(6, 2, 2, 2));
connectionPathPane.add(new UILabel(Inter.getLocText("FR-Designer_Save_Path") + ":"), BorderLayout.WEST);
this.connectionTextField = new UITextField();
connectionPathPane.add(connectionTextField, BorderLayout.CENTER);
this.connectionTextField.setEditable(false);
connectionListPane = new ConnectionListPane() {
protected void rename(String oldName, String newName) {
super.rename(oldName, newName);
renameConnection(oldName, newName);
}
};
container.add(connectionListPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Server-Define_Data_Connection");
}
public HashMap<String, String> getRenameMap() {
return connectionListPane.getRenameMap();
}
public void populate(DatasourceManagerProvider datasourceManager) {
this.connectionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME
+ File.separator + datasourceManager.fileName());
this.connectionListPane.populate(datasourceManager);
}
public void update(DatasourceManagerProvider datasourceManager) {
this.connectionListPane.update(datasourceManager);
}
/**
* 设置选中项
*
* @param index 选中项的序列号
*/
public void setSelectedIndex(int index) {
this.connectionListPane.setSelectedIndex(index);
}
/**
* 名字是否允许
*
* @return 允许返回true
*/
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);
}

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

@ -51,34 +51,16 @@ public class BorderPane extends AbstractBasicStylePane {
}
protected void initComponents() {
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);
initButtonsWithIcon();
this.setLayout(new BorderLayout(0, 6));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize1 = {p, f};
double[] rowSize1 = {p, p};
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
double[] columnSize1 = {p, f}, rowSize1 = {p, p};
Component[][] components1 = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Style") + ":"), currentLineCombo},
new Component[]{new UILabel(Inter.getLocText("Color") + ":"), currentLineColorPane},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Style") + ":"), currentLineCombo},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Color") + ":"), currentLineColorPane},
};
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components1, rowSize1, columnSize1);
double[] columnSize2 = {p, f};
double[] rowSize2 = {p, p};
double[] columnSize2 = {p, f}, rowSize2 = {p, p};
JPanel externalPane = new JPanel(new GridLayout(0, 4));
externalPane.add(topToggleButton);
externalPane.add(leftToggleButton);
@ -87,23 +69,15 @@ public class BorderPane extends AbstractBasicStylePane {
JPanel insidePane = new JPanel(new GridLayout(0, 2));
insidePane.add(horizontalToggleButton);
insidePane.add(verticalToggleButton);
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[]{externalPane, insidePane,}
};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components2, rowSize2, columnSize2);
this.setLayout(new BorderLayout(0, 6));
this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
this.currentLineColorPane.setSelectObject(Color.BLACK);
outerToggleButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean value = outerToggleButton.isSelected();
@ -113,9 +87,7 @@ public class BorderPane extends AbstractBasicStylePane {
rightToggleButton.setSelected(value);
}
});
innerToggleButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean value = innerToggleButton.isSelected();
@ -123,12 +95,22 @@ public class BorderPane extends AbstractBasicStylePane {
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
public String title4PopupWindow() {
return Inter.getLocText("Border");
return Inter.getLocText("FR-Designer_Border");
}
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

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

@ -372,7 +372,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
}
protected boolean accept(Object o){
return true;
return true;
}
private void fireSuperTargetModified() {
@ -488,15 +488,15 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
collectInfo();
return this.saveFile();
}
private boolean isCancelOperation(int operation){
return operation == FILEChooserPane.CANCEL_OPTION ||
operation == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION;
return operation == FILEChooserPane.CANCEL_OPTION ||
operation == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION;
}
private boolean isOkOperation(int operation){
return operation == FILEChooserPane.JOPTIONPANE_OK_OPTION ||
operation == FILEChooserPane.OK_OPTION;
return operation == FILEChooserPane.JOPTIONPANE_OK_OPTION ||
operation == FILEChooserPane.OK_OPTION;
}
private boolean saveAsTemplate(boolean isShowLoc) {
@ -513,8 +513,8 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
if (isCancelOperation(chooseResult)) {
fileChooser = null;
return false;
}
}
if (isOkOperation(chooseResult)) {
if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE);
@ -524,10 +524,10 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
mkNewFile(editingFILE);
fileChooser = null;
}
return saveNewFile(editingFILE, oldName);
}
protected boolean saveNewFile(FILE editingFILE, String oldName){
// 在保存之前,初始化 templateID
initForCollect(); // 如果保存新模板(新建模板直接保存,或者另存为),则添加 templateID
@ -542,23 +542,23 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getFullPathName());
return result;
}
protected void mkNewFile(FILE file){
try {
file.mkfile();
file.mkfile();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 将模板另存为可以分享出去的混淆后内置数据集模板
*
* @return 是否另存成功
*
*/
* 将模板另存为可以分享出去的混淆后内置数据集模板
*
* @return 是否另存成功
*
*/
public boolean saveShareFile(){
return true;
return true;
}
public Widget getSelectElementCase(){
return new NoneWidget();
@ -763,7 +763,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public void revert() {
}
private int getVersionCompare(String versionString){
if (StringUtils.isBlank(versionString)) {
return 0;
@ -773,7 +773,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
return ComparatorUtils.compare(versionString.substring(0, len), ProductConstants.DESIGNER_VERSION.substring(0, len));
}
private int getVersionCompareHBB(String versionString){
if (StringUtils.isBlank(versionString)) {
return 0;
@ -781,17 +781,17 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
return ComparatorUtils.compare(versionString, "HBB");
}
private boolean isHigherThanCurrent(String versionString) {
return getVersionCompare(versionString) > 0;
}
private boolean isLowerThanCurrent(String versionString) {
return getVersionCompare(versionString) < 0;
return getVersionCompare(versionString) < 0;
}
private boolean isLowerThanHBB(String versionString) {
return getVersionCompareHBB(versionString) < 0;
return getVersionCompareHBB(versionString) < 0;
}
/**
@ -801,7 +801,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public boolean isNewDesigner() {
String xmlDesignerVersion = getTarget().getXMLDesignerVersion();
if (isLowerThanHBB(xmlDesignerVersion)) {
String info = Inter.getLocText("FR-Designer_open-new-form-tip");
String info = Inter.getLocText("FR-Designer_open-new-form-tip");
String moreInfo = Inter.getLocText("FR-Designer_Server-version-tip-moreInfo");
new InformationWarnPane(info, moreInfo, Inter.getLocText("FR-Designer_Tooltips")).show();
return true;
@ -855,13 +855,13 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
* @return 是则返回true
*/
public abstract boolean isJWorkBook();
/**
* 返回当前支持的超链界面pane
* @return 超链连接界面
*/
public HyperlinkGroupPane getHyperLinkPane() {
return new HyperlinkGroupPane();
return new HyperlinkGroupPane();
}
/**
@ -916,29 +916,29 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public void requestGridFocus() {
}
/**
* 创建内置sql提交的pane
*
* @return 内置sql提交的pane
*
*
* @date 2014-10-14-下午7:39:27
*/
* 创建内置sql提交的pane
*
* @return 内置sql提交的pane
*
*
* @date 2014-10-14-下午7:39:27
*/
public DBManipulationPane createDBManipulationPane(){
return new DBManipulationPane();
return new DBManipulationPane();
}
/**
* 创建控件事件里内置sql提交的pane
*
*
* @return 内置sql提交的pane
*
*
*
* @date 2014-10-14-下午7:39:27
*/
public DBManipulationPane createDBManipulationPaneInWidget(){
return new DBManipulationInWidgetEventPane();
return new DBManipulationInWidgetEventPane();
}
/**
@ -966,15 +966,15 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public void styleChange(){
}
/**
* 创建分享模板的按钮, 目前只有jworkbook实现了
*
* @return 分享模板按钮
*
*/
* 创建分享模板的按钮, 目前只有jworkbook实现了
*
* @return 分享模板按钮
*
*/
public UIButton[] createShareButton(){
return new UIButton[0];
return new UIButton[0];
}
/**
@ -1029,4 +1029,4 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
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 {
private int patternIndex = 0; // pattern setIndex.
private final static int DEFAULT_DIM_HEIGHT = 190;
private ColorSelectBox foregroundColorPane;
private ColorSelectBox backgroundColorPane;
private PatternButton[] patternButtonArray;
public PatternBackgroundQuickPane() {
this.setLayout(new BorderLayout(0, 4));
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(contentPane, BorderLayout.NORTH);
contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
JPanel typePane2 = new JPanel();
contentPane.add(typePane2);
typePane2.setLayout(new GridLayout(0, 8, 1, 1));
@ -48,15 +47,11 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
patternButtonGroup.add(patternButtonArray[i]);
typePane2.add(patternButtonArray[i]);
}
JPanel colorPane = new JPanel(new GridLayout(0, 2));
foregroundColorPane = new ColorSelectBox(70);
backgroundColorPane = new ColorSelectBox(70);
foregroundColorPane.setSelectObject(Color.lightGray);
backgroundColorPane.setSelectObject(Color.black);
colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane));
colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane));
colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Foreground") + ":", foregroundColorPane));
colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Background") + ":", backgroundColorPane));
this.add(colorPane, BorderLayout.CENTER);
foregroundColorPane.addSelectChangeListener(colorChangeListener);
backgroundColorPane.addSelectChangeListener(colorChangeListener);
@ -65,7 +60,7 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.height = 190;
dim.height = DEFAULT_DIM_HEIGHT;
return dim;
}
@ -206,6 +201,6 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override
public String title4PopupWindow() {
return Inter.getLocText("Background-Pattern");
return Inter.getLocText("FR-Designer_Background-Pattern");
}
}

342
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.JTemplate;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils;
import com.fr.general.SiteCenter;
import com.fr.general.*;
import com.fr.general.http.HttpClient;
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.text.SimpleDateFormat;
import java.util.*;
import java.util.HashMap;
/**
* 做模板的过程和耗时收集辅助类
* Created by plough on 2017/2/21.
*/
public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private static final String FILE_NAME = "tplInfo.ser";
public class TemplateInfoCollector<T extends IOFile> implements Serializable, XMLReadable, XMLWriter {
private static final String FILE_NAME = "tpl.info";
private static final String OBJECT_FILE_NAME = "tplInfo.ser";
private static TemplateInfoCollector instance;
private HashMap<String, HashMap<String, Object>> templateInfoList;
private Map<String, HashMap<String, Object>> templateInfoList;
private String designerOpenDate; //设计器最近一次打开日期
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private static final int ONE_THOUSAND = 1000;
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")
private TemplateInfoCollector() {
@ -61,27 +85,57 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
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() {
if (instance == null) {
// 先尝试从文件读取
try{
ObjectInputStream is = new ObjectInputStream(new FileInputStream(getInfoFile()));
instance = (TemplateInfoCollector) is.readObject();
} catch (FileNotFoundException ex) {
// 如果之前没有存储过,则创建新对象
instance = new TemplateInfoCollector();
} catch (InvalidClassException ex) {
// 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖)
// 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现
instance = new TemplateInfoCollector();
}
catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage(), ex);
instance = new TemplateInfoCollector();
readXMLFile(instance, getInfoFile());
// 兼容过渡。如果没有新文件,则从老文件读取数据。以后都是读写新的 xml 文件
if (!getInfoFile().exists() && getObjectInfoFile().exists()) {
try {
ObjectInputStream is = new ObjectInputStream(new FileInputStream(getObjectInfoFile()));
instance = (TemplateInfoCollector) is.readObject();
} catch (Exception ex) {
// 什么也不做,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() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
return false;
@ -104,8 +158,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/
@SuppressWarnings("unchecked")
public String loadProcess(T t) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get("processMap");
return (String)processMap.get("process");
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get(XML_PROCESS_MAP);
return (String)processMap.get(ATTR_PROCESS);
}
/**
@ -120,9 +174,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/
private void saveInfo() {
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile()));
os.writeObject(instance);
os.close();
FileOutputStream out = new FileOutputStream(getInfoFile());
XMLTools.writeOutputStreamXML(this, out);
} catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage());
}
@ -135,8 +188,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (designerOpenFirstTime()) {
for (String key : templateInfoList.keySet()) {
HashMap<String, Object> templateInfo = templateInfoList.get(key);
int dayCount = (int)templateInfo.get("day_count") + 1;
templateInfo.put("day_count", dayCount);
int dayCount = (int)templateInfo.get(ATTR_DAY_COUNT) + 1;
templateInfo.put(ATTR_DAY_COUNT, dayCount);
}
setDesignerOpenDate();
}
@ -160,21 +213,20 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (inList(t)) { // 已有记录
templateInfo = templateInfoList.get(t.getTemplateID());
// 更新 conusmingMap
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get("consumingMap");
timeConsume += (long)consumingMap.get("time_consume"); // 加上之前的累计编辑时间
consumingMap.put("time_consume", timeConsume);
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
timeConsume += (long)consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
}
else { // 新增
templateInfo = new HashMap<>();
templateInfo.put("consumingMap", getNewConsumingMap(templateID, openTime, timeConsume));
templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume));
}
// 直接覆盖 processMap
templateInfo.put("processMap", getProcessMap(templateID, jt));
templateInfo.put(XML_PROCESS_MAP, getProcessMap(templateID, jt));
// 保存模板时,让 day_count 归零
templateInfo.put("day_count", 0);
templateInfo.put(ATTR_DAY_COUNT, 0);
templateInfoList.put(templateID, templateInfo);
@ -190,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 jarTime = GeneralUtils.readBuildNO();
String version = ProductConstants.VERSION;
consumingMap.put("username", username);
consumingMap.put("uuid", uuid);
consumingMap.put("activitykey", activitykey);
consumingMap.put("templateID", templateID);
consumingMap.put("create_time", createTime);
consumingMap.put("time_consume", timeConsume);
consumingMap.put("jar_time", jarTime);
consumingMap.put("version", version);
consumingMap.put(ATTR_USERNAME, username);
consumingMap.put(ATTR_UUID, uuid);
consumingMap.put(ATTR_ACTIVITYKEY, activitykey);
consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put(ATTR_CREATE_TIME, createTime);
consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
consumingMap.put(ATTR_JAR_TIME, jarTime);
consumingMap.put(ATTR_VERSION, version);
return consumingMap;
}
@ -205,15 +257,15 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private HashMap<String, Object> getProcessMap(String templateID, JTemplate jt) {
HashMap<String, Object> processMap = new HashMap<>();
processMap.put("templateID", templateID);
processMap.put("process", jt.getProcess());
processMap.put(ATTR_TEMPLATE_ID, templateID);
processMap.put(ATTR_PROCESS, jt.getProcess());
TemplateProcessInfo info = jt.getProcessInfo();
processMap.put("report_type", info.getReportType());
processMap.put("cell_count", info.getCellCount());
processMap.put("float_count", info.getFloatCount());
processMap.put("block_count", info.getBlockCount());
processMap.put("widget_count", info.getWidgetCount());
processMap.put(ATTR_REPORT_TYPE, info.getReportType());
processMap.put(ATTR_CELL_COUNT, info.getCellCount());
processMap.put(ATTR_FLOAT_COUNT, info.getFloatCount());
processMap.put(ATTR_BLOCK_COUNT, info.getBlockCount());
processMap.put(ATTR_WIDGET_COUNT, info.getWidgetCount());
return processMap;
}
@ -227,11 +279,11 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
String processUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single";
ArrayList<HashMap<String, String>> completeTemplatesInfo = getCompleteTemplatesInfo();
for (HashMap<String, String> templateInfo : completeTemplatesInfo) {
String jsonConsumingMap = templateInfo.get("jsonConsumingMap");
String jsonProcessMap = templateInfo.get("jsonProcessMap");
String jsonConsumingMap = templateInfo.get(JSON_CONSUMING_MAP);
String jsonProcessMap = templateInfo.get(JSON_PROCESS_MAP);
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
// 清空记录
removeFromTemplateInfoList(templateInfo.get("templateID"));
removeFromTemplateInfoList(templateInfo.get(ATTR_TEMPLATE_ID));
}
}
saveInfo();
@ -251,7 +303,12 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
}
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;
}
@ -264,21 +321,21 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
for (String key : templateInfoList.keySet()) {
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;
}
if (isTestTemplate(templateInfo)) {
testTemplateKeys.add(key);
continue;
}
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get("consumingMap");
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap");
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
String jsonConsumingMap = new JSONObject(consumingMap).toString();
String jsonProcessMap = new JSONObject(processMap).toString();
HashMap<String, String> jsonTemplateInfo = new HashMap<>();
jsonTemplateInfo.put("jsonConsumingMap", jsonConsumingMap);
jsonTemplateInfo.put("jsonProcessMap", jsonProcessMap);
jsonTemplateInfo.put("templateID", key);
jsonTemplateInfo.put(JSON_CONSUMING_MAP, jsonConsumingMap);
jsonTemplateInfo.put(JSON_PROCESS_MAP, jsonProcessMap);
jsonTemplateInfo.put(ATTR_TEMPLATE_ID, key);
completeTemplatesInfo.add(jsonTemplateInfo);
}
// 删除测试模板
@ -294,12 +351,12 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
@SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap");
int reportType = (int)processMap.get("report_type");
int cellCount = (int)processMap.get("cell_count");
int floatCount = (int)processMap.get("float_count");
int blockCount = (int)processMap.get("block_count");
int widgetCount = (int)processMap.get("widget_count");
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
int reportType = (int)processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int)processMap.get(ATTR_CELL_COUNT);
int floatCount = (int)processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int)processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int)processMap.get(ATTR_WIDGET_COUNT);
boolean isTestTemplate = false;
if (reportType == 0) { // 普通报表
isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
@ -311,6 +368,157 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
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) {
TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
tic.sendTemplateInfo();

3
designer_base/src/com/fr/design/style/color/ColorSelectConfigManager.java

@ -84,6 +84,9 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
* @param color 颜色
*/
public void addToColorQueue(Color color) {
if(color == null){
return;
}
// 过滤重复的最近使用颜色
// 因为有个后进先出的问题,最近使用的颜色需要放到最前面所以没用set
if (colors.contains(color)) {

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

@ -1,112 +1,104 @@
package com.fr.design.style.color;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.*;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import java.awt.*;
/**
* 颜色选择器更多颜色面板
* @author focus
*
* @author focus
*/
public class ColorSelectDetailPane extends BasicPane{
private static final int SELECT_PANEL_HEIGHT = 245;
// Selected color
private Color color;
// 颜色选择器面板
JColorChooser selectedPanel;
// 最近使用颜色面板
JPanel recentUsePanel;
// 预览
JPanel previewPanel;
public JColorChooser getSelectedPanel() {
return selectedPanel;
}
public void setSelectedPanel(JColorChooser selectedPanel) {
this.selectedPanel = selectedPanel;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public ColorSelectDetailPane() {
super();
}
public ColorSelectDetailPane(Color color){
if(color == null){
color = Color.white;
}
this.color = color;
initComponents();
}
@Override
protected String title4PopupWindow() {
return null;
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
// 颜色选择器面板
selectedPanel = new JColorChooser(this.color);
selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(),SELECT_PANEL_HEIGHT));
AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels();
for(int i=0;i<choosers.length;i++){
selectedPanel.removeChooserPanel(choosers[i]);
}
selectedPanel.setPreviewPanel(new JPanel());
AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel();
AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel();
selectedPanel.addChooserPanel(swatchChooserPanel);
selectedPanel.addChooserPanel(customChooserPanel);
this.add(selectedPanel, BorderLayout.NORTH);
// 最近使用面板
recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Used"));
RecentUseColorPane recent = new RecentUseColorPane(selectedPanel);
recentUsePanel.add(recent);
this.add(recentUsePanel,BorderLayout.CENTER);
selectedPanel.setPreviewPanel(new JPanel());
// 预览
previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(Inter.getLocText("FR-Designer_Preview"));
final ColorChooserPreview colorChooserPreview = new ColorChooserPreview();
ColorSelectionModel model = selectedPanel.getSelectionModel();
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
ColorSelectionModel model = (ColorSelectionModel) e.getSource();
colorChooserPreview.setMyColor(model.getSelectedColor());
colorChooserPreview.paint(colorChooserPreview.getGraphics());
}
});
previewPanel.add(colorChooserPreview);
this.add(previewPanel, BorderLayout.SOUTH);
}
public class ColorSelectDetailPane extends BasicPane {
private static final int SELECT_PANEL_HEIGHT = 245;
// Selected color
private Color color;
// 颜色选择器面板
private JColorChooser selectedPanel;
// 最近使用颜色面板
private JPanel recentUsePanel;
// 预览
private JPanel previewPanel;
public JColorChooser getSelectedPanel() {
return selectedPanel;
}
public void setSelectedPanel(JColorChooser selectedPanel) {
this.selectedPanel = selectedPanel;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public ColorSelectDetailPane(Color color) {
if (color == null) {
color = Color.white;
}
this.color = color;
initComponents();
}
@Override
protected String title4PopupWindow() {
return null;
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
// 颜色选择器面板
selectedPanel = new JColorChooser(this.color);
selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT));
AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels();
for (int i = 0; i < choosers.length; i++) {
selectedPanel.removeChooserPanel(choosers[i]);
}
selectedPanel.setPreviewPanel(new JPanel());
AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel();
AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel();
selectedPanel.addChooserPanel(swatchChooserPanel);
selectedPanel.addChooserPanel(customChooserPanel);
this.add(selectedPanel, BorderLayout.NORTH);
// 最近使用面板
recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Used"));
RecentUseColorPane recent = new RecentUseColorPane(selectedPanel);
recentUsePanel.add(recent);
this.add(recentUsePanel, BorderLayout.CENTER);
selectedPanel.setPreviewPanel(new JPanel());
// 预览
previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(Inter.getLocText("FR-Designer_Preview"));
final ColorChooserPreview colorChooserPreview = new ColorChooserPreview();
ColorSelectionModel model = selectedPanel.getSelectionModel();
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
ColorSelectionModel model = (ColorSelectionModel) e.getSource();
colorChooserPreview.setMyColor(model.getSelectedColor());
colorChooserPreview.paint(colorChooserPreview.getGraphics());
}
});
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;
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.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.Inter;
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
@ -30,94 +27,95 @@ import com.fr.design.utils.gui.GUICoreUtils;
public class ColorSelectPane extends TransparentPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L;
private Color color = null; //color
private Color color = null; //color
//color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
ColorSelectDetailPane pane;
/* default */ ColorSelectDetailPane pane;
/**
* Constructor.
*/
public ColorSelectPane() {
super(true);
initialCompents(true);
super(true);
initialCompents(true);
}
public ColorSelectPane(boolean isSupportTransparent) {
super(isSupportTransparent);
initialCompents(isSupportTransparent);
}
private void initialCompents(boolean isSupportTransparent) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doTransparent();
}
});
}
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
centerPane.add(getRow1Pane());
JPanel menuColorPane1 = getMenuColorPane();
centerPane.add(menuColorPane1);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doTransparent();
}
});
}
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
centerPane.add(getRow1Pane());
JPanel menuColorPane1 = getMenuColorPane();
centerPane.add(menuColorPane1);
Color[] colorArray = this.getColorArray();
for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i];
menuColorPane1.add(new ColorCell(color, this));
}
centerPane.add(Box.createVerticalStrut(1));
UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
customButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
customButtonPressed();
}
});
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));
centerPane1.add(customButton, BorderLayout.NORTH);
centerPane.add(centerPane1);
}
protected JPanel getMenuColorPane() {
JPanel menuColorPane = new JPanel();
menuColorPane.setLayout(new GridLayout(5, 8, 1, 1));
menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
return menuColorPane;
}
// 第一行,1个取色按钮 + 7个最近使用的颜色
protected JPanel getRow1Pane() {
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
// 最近使用
UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, true);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane());
return row1Pane;
}
protected Color[] getColorArray(){
for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i];
menuColorPane1.add(new ColorCell(color, this));
}
centerPane.add(Box.createVerticalStrut(1));
UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
customButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
customButtonPressed();
}
});
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));
centerPane1.add(customButton, BorderLayout.NORTH);
centerPane.add(centerPane1);
}
protected JPanel getMenuColorPane() {
JPanel menuColorPane = new JPanel();
menuColorPane.setLayout(new GridLayout(5, 8, 1, 1));
menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
return menuColorPane;
}
// 第一行,1个取色按钮 + 1个留空的单元格 + 6个最近使用的颜色
protected JPanel getRow1Pane() {
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
// 最近使用
UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, this, true, true);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane());
return row1Pane;
}
protected Color[] getColorArray() {
return ColorFactory.MenuColors;
}
@ -125,15 +123,16 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/**
* Add change listener.
* 增加监听
* @param 监听
*
* @param changeListener
*/
public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener);
}
@Override
protected String title4PopupWindow() {
return "Color";
return "Color";
}
/**
@ -166,38 +165,36 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/**
* 选中颜色
* @param 颜色单元格
*
*/
@Override
public void colorSetted(ColorCell colorCell) {
colorCell.repaint();
}
/**
* 初始化中央面板
* @param centerPane 中央面板
*
*/
@Override
public void initCenterPaneChildren(JPanel centerPane) {
GUICoreUtils.initCenterPaneChildren(centerPane, this);
}
/**
* 透明
*/
@Override
public void doTransparent() {
this.setColor(null);
}
/**
* 更多颜色
*/
@Override
public void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
}
@Override
public void colorSetted(ColorCell colorCell) {
colorCell.repaint();
}
/**
* 初始化中央面板
*
* @param centerPane 中央面板
*/
@Override
public void initCenterPaneChildren(JPanel centerPane) {
GUICoreUtils.initCenterPaneChildren(centerPane, this);
}
/**
* 透明
*/
@Override
public void doTransparent() {
this.setColor(null);
}
/**
* 更多颜色
*/
@Override
public void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE);
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;
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.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicPane;
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
* @since 2012-5-29上午10:39:35
*/
public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L;
private Color color = null; // color
// color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
// 颜色选择器
private ColorSelectDetailPane pane;
// 是否支持透明
private boolean isSupportTransparent;
private final static int TRANSPANENT_WINDOW_HEIGHT = 165;
private final static int WINDWO_HEIGHT = 150;
// 最近使用颜色
UsedColorPane usedColorPane;
/**
* Constructor.
*/
public NewColorSelectPane() {
this(false);
}
/**
* Constructor.
*/
public NewColorSelectPane(boolean isSupportTransparent) {
this.isSupportTransparent = isSupportTransparent;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doTransparent();
}
});
}
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
// 第一行
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
centerPane.add(row1Pane);
// 最近使用
usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, false);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane());
JPanel menuColorPane1 = new JPanel();
centerPane.add(menuColorPane1);
menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1));
menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
for (int i = 0; i < ColorFactory.MenuColors.length; i++) {
menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this));
}
centerPane.add(Box.createVerticalStrut(1));
// mod by anchore 16/11/16
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() {
@Override
public void mousePressed(MouseEvent e) {
customButtonPressed();
}
});
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8));
centerPane1.add(customButton, BorderLayout.NORTH);
centerPane.add(centerPane1);
}
/**
* 添加监听
* @param 监听列表
* Add change listener.
*/
public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener);
}
@Override
protected String title4PopupWindow() {
return "Color";
}
/**
* 获取颜色
* @return 颜色
* Return the color.
*/
public Color getColor() {
return color;
}
/**
* 获取颜色
*
* @return 颜色
*/
public Color getNotNoneColor() {
if (color == null) {
setColor(Color.WHITE);
return Color.WHITE;
}
return color;
}
/**
* Set the color.
*
* @param color
* the new color.
*/
@Override
public void setColor(Color color) {
this.color = color;
// fire color change.
if (!colorChangeListenerList.isEmpty()) {
ChangeEvent evt = new ChangeEvent(this);
for (int i = 0; i < colorChangeListenerList.size(); i++) {
this.colorChangeListenerList.get(i).stateChanged(evt);
}
}
ColorSelectConfigManager.getInstance().addToColorQueue(color);
this.repaint();
}
/**
* 设置颜色
* @param 颜色位置
*/
@Override
public void colorSetted(ColorCell colorCell) {
colorCell.repaint();
}
protected void doTransparent() {
setColor(null);
}
protected void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
}
@Override
public Dimension getPreferredSize() {
if(isSupportTransparent){
return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT);
}
return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT);
}
/**
* 更新最近使用颜色
*
*/
public void updateUsedColor(){
usedColorPane.updateUsedColor();
}
private static final long serialVersionUID = -8634152305687249392L;
private Color color = null; // color
// color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
// 颜色选择器
private ColorSelectDetailPane pane;
// 是否支持透明
private boolean isSupportTransparent;
private final static int TRANSPANENT_WINDOW_HEIGHT = 165;
private final static int WINDWO_HEIGHT = 150;
// 最近使用颜色
private UsedColorPane usedColorPane;
/**
* Constructor.
*/
public NewColorSelectPane() {
this(false);
}
/**
* Constructor.
*/
public NewColorSelectPane(boolean isSupportTransparent) {
this.isSupportTransparent = isSupportTransparent;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doTransparent();
}
});
}
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
// 第一行
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
centerPane.add(row1Pane);
// 最近使用
usedColorPane = new UsedColorPane(1, 8, 1, this, true, false);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane());
JPanel menuColorPane1 = new JPanel();
centerPane.add(menuColorPane1);
menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1));
menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
for (int i = 0; i < ColorFactory.MenuColors.length; i++) {
menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this));
}
centerPane.add(Box.createVerticalStrut(1));
// mod by anchore 16/11/16
UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
customButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
customButtonPressed();
}
});
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8));
centerPane1.add(customButton, BorderLayout.NORTH);
centerPane.add(centerPane1);
}
/**
* 添加监听
*
* @param 监听列表 Add change listener.
*/
public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener);
}
@Override
protected String title4PopupWindow() {
return "Color";
}
/**
* 获取颜色
*
* @return 颜色
* Return the color.
*/
public Color getColor() {
return color;
}
/**
* 获取颜色
*
* @return 颜色
*/
public Color getNotNoneColor() {
if (color == null) {
setColor(Color.WHITE);
return Color.WHITE;
}
return color;
}
/**
* Set the color.
*
* @param color the new color.
*/
@Override
public void setColor(Color color) {
this.color = color;
// fire color change.
if (!colorChangeListenerList.isEmpty()) {
ChangeEvent evt = new ChangeEvent(this);
for (int i = 0; i < colorChangeListenerList.size(); i++) {
this.colorChangeListenerList.get(i).stateChanged(evt);
}
}
ColorSelectConfigManager.getInstance().addToColorQueue(color);
this.repaint();
}
/**
* 设置颜色
*
* @param 颜色位置
*/
@Override
public void colorSetted(ColorCell colorCell) {
colorCell.repaint();
}
protected void doTransparent() {
setColor(null);
}
protected void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
}
@Override
public Dimension getPreferredSize() {
if (isSupportTransparent) {
return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT);
}
return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT);
}
/**
* 更新最近使用颜色
*/
public void updateUsedColor() {
usedColorPane.updateUsedColor();
}
}

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

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

50
designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java

@ -31,17 +31,18 @@ public class MinMaxValuePane extends JPanel {
protected UITextField secUnitField;
public MinMaxValuePane() {
minCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Min_Value"}));
minValueField = new UITextField(6);
maxCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Max_Value"}));
maxValueField = new UITextField(6);
isCustomMainUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_MainGraduationUnit"));
mainUnitField = new UITextField(6);
isCustomSecUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_SecondGraduationUnit"));
secUnitField = new UITextField(6);
minCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Min_Value"}));
minValueField = new UITextField(6);
maxCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Max_Value"}));
maxValueField = new UITextField(6);
isCustomMainUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_MainGraduationUnit"));
mainUnitField = new UITextField(6);
isCustomSecUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_SecondGraduationUnit"));
secUnitField = new UITextField(6);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = { p, f };
double[] columnSize = {p, f};
Component[][] components = getPanelComponents();
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, getRowSize(p), columnSize);
@ -53,25 +54,26 @@ public class MinMaxValuePane extends JPanel {
protected double[] getRowSize(double p) {
return new double[]{p, p, p, p};
}
protected void addComponentListener(Component[][] components) {
for (int i = 0; i < components.length; i++) {
addListener((UICheckBox) components[i][0]);
ChartSwingUtils.addListener((UICheckBox) components[i][0], (UITextField) components[i][1]);
}
}
protected void addListener(UICheckBox checkBox) {
checkBox.addActionListener(new ActionListener() {
protected void addComponentListener(Component[][] components) {
for (int i = 0; i < components.length; i++) {
addListener((UICheckBox) components[i][0]);
ChartSwingUtils.addListener((UICheckBox) components[i][0], (UITextField) components[i][1]);
}
}
protected void addListener(UICheckBox checkBox) {
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkBoxUse();
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
checkBoxUse();
}
});
}
protected Component[][] getPanelComponents() {
return new Component[][]{
return new Component[][]{
new Component[]{minCheckBox, minValueField},
new Component[]{maxCheckBox, maxValueField},
new Component[]{isCustomMainUnitBox, mainUnitField},

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

@ -77,17 +77,17 @@ public class ChartTextAttrPane extends BasicPane {
public void populate(FRFont frFont) {
UIObserverListener listener = fontNameComboBox == null ? null : fontNameComboBox.getUiObserverListener();
removeAllComboBoxListener();
if (frFont == null) {
return;
}
fontNameComboBox.setSelectedItem(frFont.getFamily());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
if(fontSizeComboBox != null) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
}
if (fontColor != null) {
fontColor.setColor(frFont.getForeground());
if (frFont != null) {
fontNameComboBox.setSelectedItem(frFont.getFamily());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
if(fontSizeComboBox != null) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
}
if (fontColor != null) {
fontColor.setColor(frFont.getForeground());
}
}
//更新结束后,注册监听器

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

@ -1,346 +1,341 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import java.awt.*;
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
//是不是添加到父容器上
private boolean isAdd2ParentLayout = false;
private HoverPainter painter;
public FRAbsoluteLayoutAdapter(XLayoutContainer container) {
super(container);
painter = new FRAbsoluteLayoutPainter(container);
initMinSize();
}
private void initMinSize() {
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
minWidth = layout.getActualMinWidth();
minHeight = layout.getActualMinHeight();
actualVal = layout.getAcualInterval();
margin = layout.toData().getMargin();
}
@Override
public HoverPainter getPainter() {
return painter;
}
/**
* 是否能在指定位置添加组件
*
* @param creator 组件
* @param x 坐标x
* @param y 坐标y
* @return 能则返回true
*/
//这个地方的逻辑非常复杂,
// 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围,
// 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套)
// 3.当前绝对布局可编辑,那么控件添加
@Override
public boolean accept(XCreator creator, int x, int y) {
Component comp = container.getComponentAt(x, y);
//布局控件要先判断是不是可编辑
//可以编辑,按原有逻辑判断
//不可编辑,当成一整个控件处理
if (comp == null) {
return false;
}
//参数面板内的组件不允许拖往绝对布局中
if (creator.getParent() != null && ((XCreator) creator.getParent()).acceptType(XWParameterLayout.class)) {
Rectangle rec = creator.getBounds();
rec.y = creator.getParent().getHeight() - rec.height;
creator.setBounds(rec);
return false;
}
//判断组件能不能拖入绝对布局
if (!creator.canEnterIntoAbsolutePane()) {
return false;
}
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout();
if (topLayout != null) {
if (topLayout.isEditable()) {
return topLayoutAccept(creator, x, y);
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false;
} else {
return acceptWidget(x, y);
}
} else {
FRLogger.getLogger().error("top layout is null!");
}
return false;
}
//topLayout假如可以编辑的话就往里面添加组件
private boolean topLayoutAccept(XCreator creator, int x, int y) {
//允许组件重叠,可以不判断有没有和当前控件重叠
//先计算当前控件的位置
int creatorX, creatorY;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
creatorX = creatorRectangle.x;
creatorY = creatorRectangle.y;
} else {
//这边计算得到的组件其实位置是正确的,
//因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的,
// 例如高度为21,那么就是+10-10;
// 高度为20,那么就是+10-10; 没区别
int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2;
creatorX = x - w;
creatorY = y - h;
}
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
return false;
}
if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()) {
return false;
}
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight()
&& creator.getWidth() <= container.getWidth();
}
/**
* 判断是否鼠标在组件的三等分区域如果组件在布局管理器中间上下左右都可能会三等分
*
* @param parentComp 鼠标所在区域的组件
* @param x 坐标x
* @param y 坐标y
* @return 是则返回true
*/
public boolean isTrisectionArea(Component parentComp, int x, int y) {
XCreator creator = (XCreator) parentComp;
trisectAreaDirect = 0;
if (container.getComponentCount() <= 1) {
return false;
}
int maxWidth = parentComp.getWidth();
int maxHeight = parentComp.getHeight();
int xL = parentComp.getX();
int yL = parentComp.getY();
// 组件宽高的十分之一和默认值取大
int minRangeWidth = Math.max(maxWidth / BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
int minRangeHeight = Math.max(maxHeight / BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
if (y < yL + minRangeHeight) {
// 在组件上侧三等分
trisectAreaDirect = COMP_TOP;
} else if (y > yL + maxHeight - minRangeHeight) {
// 在组件下侧三等分
trisectAreaDirect = COMP_BOTTOM;
} else if (x < xL + minRangeWidth) {
// 在组件左侧三等分
trisectAreaDirect = COMP_LEFT;
} else if (x > xL + maxWidth - minRangeWidth) {
// 在组件右侧三等分
trisectAreaDirect = COMP_RIGHT;
}
// tab布局的边界特殊处理,不进行三等分
if (!creator.getTargetChildrenList().isEmpty()) {
return false;
}
return !ComparatorUtils.equals(trisectAreaDirect, 0);
}
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围
private boolean acceptWidget(int x, int y) {
isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y);
//如果当前处于边缘地带, 那么就把他贴到父容器上
XLayoutContainer parent = container.findNearestFit();
container = parent != null ? parent : container;
isAdd2ParentLayout = true;
int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth();
//上半部分高度
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY();
//下半部分高度
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY();
if (isCrossPointArea(comp, x, y)) {
return canAcceptWhileCrossPoint(comp, x, y);
}
if (isTrisectionArea(comp, x, y)) {
return canAcceptWhileTrisection(comp, x, y);
}
boolean horizonValid = componentWidth >= minWidth * 2 + actualVal;
boolean verticalValid = componentHeight >= minHeight * 2 + actualVal;
return y > upHeight && y < downHeight ? horizonValid : verticalValid;
}
/**
* 组件的ComponentAdapter在添加组件时如果发现布局管理器不为空会继而调用该布局管理器的
* addComp方法来完成组件的具体添加在该方法内布局管理器可以提供额外的功能
*
* @param creator 被添加的新组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
* @return 是否添加成功成功返回true否则false
*/
@Override
public boolean addBean(XCreator creator, int x, int y) {
Rectangle rect = ComponentUtils.getRelativeBounds(container);
int posX = x + rect.x;
int posY = y + rect.y;
if (!accept(creator, x, y)) {
return false;
}
addComp(creator, posX, posY);
((XWidgetCreator) creator).recalculateChildrenSize();
return true;
}
@Override
protected void addComp(XCreator creator, int x, int y) {
if (!isAdd2ParentLayout) {
Rectangle r = ComponentUtils.getRelativeBounds(container);
x = x - r.x;
y = y - r.y;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
x = creatorRectangle.x - r.x;
y = creatorRectangle.y - r.y;
} else {
int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2;
x = x - w;
y = y - h;
}
fix(creator, x, y);
if (creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
container.add(creator, creator.toData().getWidgetName(), 0);
}
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator);
updateCreatorBackBound();
LayoutUtils.layoutRootContainer(container);
} else {
fixAbsolute(creator, x, y);
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
container.add(creator, creator.toData().getWidgetName(), 0);
}
XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget
layout.updateBoundsWidget();
updateCreatorBackBound();
}
}
private void updateCreatorBackBound() {
for (int i = 0, size = container.getComponentCount(); i < size; i++) {
XCreator creator = (XCreator) container.getComponent(i);
creator.updateChildBound(minHeight);
creator.setBackupBound(creator.getBounds());
}
}
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight());
container.add(parentPanel, child.toData().getWidgetName(), 0);
}
/**
* 新拖入组件时计算调整其他关联组件位置大小
*
* @param child 新拖入的组件
* @param x 鼠标所在x坐标
* @param y 鼠标所在y坐标
*/
private void fixAbsolute(XCreator child, int x, int y) {
Component parentComp = container.getComponentAt(x, y);
if (container.getComponentCount() == 0) {
child.setLocation(0, 0);
child.setSize(parentComp.getWidth(), parentComp.getHeight());
} else if (isCrossPointArea(parentComp, x, y)) {
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
fixCrossPointArea(parentComp, child, x, y);
return;
} else if (isTrisectionArea(parentComp, x, y)) {
// 在边界三等分区域,就不再和组件二等分了
fixTrisect(parentComp, child, x, y);
return;
} else {
fixHalve(parentComp, child, x, y);
}
}
/**
* 组件拖拽后调整大小
*
* @param creator 组件
*/
@Override
public void fix(XCreator creator) {
WAbsoluteLayout wabs = (WAbsoluteLayout) container.toData();
fix(creator, creator.getX(), creator.getY());
wabs.setBounds(creator.toData(), creator.getBounds());
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator);
}
/**
* 调整组件大小到合适尺寸位置
*
* @param creator 组件
* @param x 坐标x
* @param y 坐标y
*/
public void fix(XCreator creator, int x, int y) {
int height = creator.getHeight();
int width = creator.getWidth();
if (x < 0) {
x = container.getX();
} else if (x + creator.getWidth() > container.getWidth()) {
x = container.getWidth() - width;
}
if (y < 0) {
y = container.getY();
} else if (y + creator.getHeight() > container.getHeight()) {
y = container.getHeight() - height;
}
creator.setBounds(x, y, width, height);
}
@Override
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
return new BoundsGroupModel((XWAbsoluteLayout) container, creator);
}
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container;
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
}
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import java.awt.*;
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
//是不是添加到父容器上
private boolean isAdd2ParentLayout = false;
private HoverPainter painter;
public FRAbsoluteLayoutAdapter(XLayoutContainer container) {
super(container);
painter = new FRAbsoluteLayoutPainter(container);
initMinSize();
}
private void initMinSize() {
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
minWidth = layout.getActualMinWidth();
minHeight = layout.getActualMinHeight();
actualVal = layout.getAcualInterval();
margin = layout.toData().getMargin();
}
@Override
public HoverPainter getPainter() {
return painter;
}
/**
* 是否能在指定位置添加组件
* @param creator 组件
* @param x 坐标x
* @param y 坐标y
* @return 能则返回true
*/
//这个地方的逻辑非常复杂,
// 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围,
// 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套)
// 3.当前绝对布局可编辑,那么控件添加
@Override
public boolean accept(XCreator creator, int x, int y) {
Component comp = container.getComponentAt(x, y);
//布局控件要先判断是不是可编辑
//可以编辑,按原有逻辑判断
//不可编辑,当成一整个控件处理
if (comp == null){
return false;
}
//参数面板内的组件不允许拖往绝对布局中
if (creator.getParent() != null && ((XCreator)creator.getParent()).acceptType(XWParameterLayout.class)){
Rectangle rec = creator.getBounds();
rec.y = creator.getParent().getHeight() - rec.height;
creator.setBounds(rec);
return false;
}
//判断下组件能不能拖入绝对布局
if (!creator.canEnterIntoAbsolutePane()){
return false;
}
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null){
if (topLayout.isEditable()){
return topLayoutAccept(creator, x, y);
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false;
} else {
return acceptWidget(x, y);
}
} else {
FRLogger.getLogger().error("top layout is null!");
}
return false;
}
//topLayout假如可以编辑的话就往里面添加组件
private boolean topLayoutAccept(XCreator creator, int x, int y) {
//允许组件重叠,可以不判断有没有和当前控件重叠
//先计算当前控件的位置
int creatorX, creatorY;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
creatorX = creatorRectangle.x;
creatorY = creatorRectangle.y;
} else {
//这边计算得到的组件其实位置是正确的,
//因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的,
// 例如高度为21,那么就是+10-10;
// 高度为20,那么就是+10-10; 没区别
int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2;
creatorX = x - w;
creatorY = y - h;
}
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
return false;
}
if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()){
return false;
}
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight()
&& creator.getWidth() <= container.getWidth();
}
/**
* 判断是否鼠标在组件的三等分区域如果组件在布局管理器中间上下左右都可能会三等分
* @param parentComp 鼠标所在区域的组件
* @param x 坐标x
* @param y 坐标y
* @return 是则返回true
*/
public boolean isTrisectionArea(Component parentComp, int x, int y) {
XCreator creator = (XCreator)parentComp;
trisectAreaDirect = 0;
if (container.getComponentCount()<=1) {
return false;
}
int maxWidth = parentComp.getWidth();
int maxHeight = parentComp.getHeight();
int xL = parentComp.getX();
int yL = parentComp.getY();
// 组件宽高的十分之一和默认值取大
int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
if(y<yL+minRangeHeight ) {
// 在组件上侧三等分
trisectAreaDirect = COMP_TOP;
} else if(y>yL+maxHeight-minRangeHeight) {
// 在组件下侧三等分
trisectAreaDirect = COMP_BOTTOM;
} else if (x<xL+minRangeWidth) {
// 在组件左侧三等分
trisectAreaDirect = COMP_LEFT;
} else if(x>xL+maxWidth-minRangeWidth) {
// 在组件右侧三等分
trisectAreaDirect = COMP_RIGHT;
}
// tab布局的边界特殊处理,不进行三等分
if(!creator.getTargetChildrenList().isEmpty()){
return false;
}
return !ComparatorUtils.equals(trisectAreaDirect, 0);
}
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围
private boolean acceptWidget(int x, int y) {
isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y);
//如果当前处于边缘地带, 那么就把他贴到父容器上
XLayoutContainer parent = container.findNearestFit();
container = parent != null ? parent : container;
isAdd2ParentLayout = true;
int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth();
//上半部分高度
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY();
//下半部分高度
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY();
if (isCrossPointArea(comp, x, y)) {
return canAcceptWhileCrossPoint(comp, x, y);
}
if (isTrisectionArea(comp, x, y)) {
return canAcceptWhileTrisection(comp, x, y);
}
boolean horizonValid = componentWidth >= minWidth * 2 + actualVal;
boolean verticalValid = componentHeight >= minHeight * 2 + actualVal;
return y > upHeight && y < downHeight ? horizonValid : verticalValid;
}
/**
* 组件的ComponentAdapter在添加组件时如果发现布局管理器不为空会继而调用该布局管理器的
* addComp方法来完成组件的具体添加在该方法内布局管理器可以提供额外的功能
*
* @param creator 被添加的新组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
* @return 是否添加成功成功返回true否则false
*/
@Override
public boolean addBean(XCreator creator, int x, int y) {
Rectangle rect = ComponentUtils.getRelativeBounds(container);
int posX = x + rect.x;
int posY = y + rect.y;
if (!accept(creator, x, y)) {
return false;
}
addComp(creator, posX, posY);
((XWidgetCreator) creator).recalculateChildrenSize();
return true;
}
@Override
protected void addComp(XCreator creator, int x, int y) {
if(!isAdd2ParentLayout) {
Rectangle r = ComponentUtils.getRelativeBounds(container);
x = x - r.x;
y = y - r.y;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
x = creatorRectangle.x - r.x;
y = creatorRectangle.y - r.y;
} else {
int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2;
x = x - w;
y = y - h;
}
fix(creator, x, y);
if (creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
container.add(creator, creator.toData().getWidgetName(),0);
}
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator);
updateCreatorBackBound();
LayoutUtils.layoutRootContainer(container);
}else{
fixAbsolute(creator, x, y);
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
container.add(creator, creator.toData().getWidgetName(),0);
}
XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget
layout.updateBoundsWidget();
updateCreatorBackBound();
}
}
private void updateCreatorBackBound() {
for (int i=0,size=container.getComponentCount(); i<size; i++) {
XCreator creator = (XCreator) container.getComponent(i);
creator.updateChildBound(minHeight);
creator.setBackupBound(creator.getBounds());
}
}
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight());
container.add(parentPanel, child.toData().getWidgetName(),0);
}
/**
* 新拖入组件时计算调整其他关联组件位置大小
* @param child 新拖入的组件
* @param x 鼠标所在x坐标
* @param y 鼠标所在y坐标
*/
private void fixAbsolute(XCreator child, int x, int y) {
Component parentComp = container.getComponentAt(x, y);
if (container.getComponentCount()==0){
child.setLocation(0, 0);
child.setSize(parentComp.getWidth(), parentComp.getHeight());
} else if(isCrossPointArea(parentComp, x, y)){
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
fixCrossPointArea(parentComp, child, x, y);
return;
} else if (isTrisectionArea(parentComp, x, y)) {
// 在边界三等分区域,就不再和组件二等分了
fixTrisect(parentComp, child, x, y);
return;
} else{
fixHalve(parentComp, child, x, y);
}
}
/**
* 组件拖拽后调整大小
* @param creator 组件
*/
@Override
public void fix(XCreator creator) {
WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData();
fix(creator,creator.getX(),creator.getY());
wabs.setBounds(creator.toData(),creator.getBounds());
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator);
}
/**
* 调整组件大小到合适尺寸位置
* @param creator 组件
* @param x 坐标x
* @param y 坐标y
*/
public void fix(XCreator creator ,int x, int y) {
int height = creator.getHeight();
int width = creator.getWidth();
if (x < 0) {
x = container.getX();
} else if (x + creator.getWidth() > container.getWidth()) {
x = container.getWidth() - width;
}
if (y < 0) {
y = container.getY();
} else if (y + creator.getHeight() > container.getHeight()) {
y = container.getHeight() - height;
}
creator.setBounds(x, y, width, height);
}
@Override
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
return new BoundsGroupModel((XWAbsoluteLayout)container, creator);
}
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container;
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
}
}

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

@ -16,19 +16,17 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRFitLayoutConstraints;
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.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* 自适应布局的容器适配器
*
@ -50,7 +48,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public void setEdit(boolean edit) {
isEdit = edit;
}
/**
* 构造函数
*
@ -133,7 +131,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y);
if (comp == null || checkInterval(comp)) {
if (comp == null || checkInterval(comp)) {
return false;
}
//如果当前处于边缘地带, 那么就把他贴到父容器上
@ -269,13 +267,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
}
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) {
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) {
return mainLayout.getBounds();
}
private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) {
// zhouping: REPORT-2334 表单tab布局中图表放大缩小会明显
// 这边不需要单独处理参数面板高度了,下面的方法中获取的是XWCardMainBorderLayout相对坐标
// zhouping: REPORT-2334 表单tab布局中图表放大缩小会明显
// 这边不需要单独处理参数面板高度了,下面的方法中获取的是XWCardMainBorderLayout相对坐标
Rectangle rec = getLayoutBound(mainLayout);
// XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响
// 减掉之后可以按照它原来的逻辑执行
@ -341,13 +339,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* 拖拽控件边框后根据控件的大小尺寸进行相关组件的调整
*
* @param backupBound 边界备份
* @param bounds 组件边界
* @param xCreator 组件
* @param row 选中的行
* @param difference 偏移量
* @param bounds 组件边界
* @param xCreator 组件
* @param row 选中的行
* @param 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);
if (parent != null) {
Rectangle rec = ComponentUtils.getRelativeBounds(parent);
@ -358,17 +356,17 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
//处理左右延伸
switch (row) {
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;
}
break;
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;
}
break;
}
bounds.setLocation(x, y);
bounds.setLocation(x, y);
xCreator.setBackupBound(backupBound);
xCreator.setBounds(bounds);
this.fix(xCreator);
@ -412,7 +410,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
// 根据需要依附的位置调整拖拽的坐标值
private int adjustCoordinateByDependingLine(int coordinate, int[] coordinates) {
if (!isEdit) {
if (!isEdit) {
for (int i = 0; i < coordinates.length; i++) {
if (coordinate == coordinates[i]) {
continue;
@ -428,7 +426,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
// 根据需要依附的位置调整拖拽的距离
private int adjustDiffByDependingLine(int coordinate, int[] coordinates, int diff) {
if (!isEdit) {
if (!isEdit) {
for (int i = 0; i < coordinates.length; i++) {
if (coordinate + diff > coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) {
diff = coordinates[i] - coordinate;
@ -546,8 +544,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minWidth - getMinWidth(leftComps));
}
//重新计算左右两侧组件size、point
if (calculateLefttRelatComponent(difference)) {
calculateRightRelatComponent(objx + difference, -difference);
if (calculateLefttRelatComponent(difference)) {
calculateRightRelatComponent(objx + difference, -difference);
}
}
@ -662,8 +660,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minHeight - getMinHeight(upComps));
}
//重新计算上下两侧组件size、point
if (calculateUpRelatComponent(difference)) {
calculateDownRelatComponent(objY + difference, -difference);
if (calculateUpRelatComponent(difference)) {
calculateDownRelatComponent(objY + difference, -difference);
}
}
@ -744,13 +742,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
int height = creatorHeight;
calculateRelatedComponent(x, y, width, height);
if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) {
calculateRightRelatComponent(x, width + actualVal);
calculateRightRelatComponent(x, width + actualVal);
} else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) {
calculateLefttRelatComponent(width + actualVal);
calculateLefttRelatComponent(width + actualVal);
} else if (!downComps.isEmpty() && getAllWidth(downComps) == width) {
calculateDownRelatComponent(y, height + actualVal);
calculateDownRelatComponent(y, height + actualVal);
} else if (!upComps.isEmpty() && getAllWidth(upComps) == width) {
calculateUpRelatComponent(height + actualVal);
calculateUpRelatComponent(height + actualVal);
} else {
// 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理
calculateNoRelatedComponent(x, y, width, height);
@ -1013,7 +1011,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
setAdjustedSize(tabLayout, offset, isHor);
for (int m = 0; m < tabLayout.getComponentCount(); 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());
}
adjustCreatorsSize(percent, tabLayout, isHor);
@ -1056,7 +1054,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* @param objX 调整后的坐标x
* @param objWidth 调整后的宽度
*/
protected void calculateRightRelatComponent(int objX, int objWidth) {
protected void calculateRightRelatComponent(int objX, int objWidth) {
int count = rightComps.size();
for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) rightComps.get(i);
@ -1096,7 +1094,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 删除或拉伸控件左边框时 调整左侧的组件位置大小
*/
protected boolean calculateLefttRelatComponent(int objWidth) {
protected boolean calculateLefttRelatComponent(int objWidth) {
if (isBeyondAdjustWidthScope(objWidth)) {
return false;
}
@ -1114,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();
for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) downComps.get(i);
@ -1154,7 +1152,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 删除或拉伸上边框 调整上方的组件位置大小
*/
protected boolean calculateUpRelatComponent(int objHeight) {
protected boolean calculateUpRelatComponent(int objHeight) {
if (isBeyondAdjustHeightScope(objHeight)) {
return false;
}

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

@ -11,6 +11,7 @@ import com.fr.design.mainframe.FormSelection;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WParameterLayout;
import java.awt.*;
@ -24,7 +25,7 @@ public abstract class AccessDirection implements Direction {
private int ymin;
private int xmin;
abstract int getCursor();
abstract int getCursor();
protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer,
Rectangle oldBounds);
@ -51,14 +52,14 @@ public abstract class AccessDirection implements Direction {
x = designer.getRootComponent().getWidth();
}
//参数面板可以无下限拉长
if (y < 0) {
y = 0;
} else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent()
if (y < 0) {
y = 0;
} else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent()
&& !designer.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWParameterLayout.class)) {
y = designer.getRootComponent().getHeight() + designer.getParaHeight();
}
return new Point(x, y);
}
y = designer.getRootComponent().getHeight() + designer.getParaHeight();
}
return new Point(x, y);
}
protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) {
boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT;
@ -95,10 +96,10 @@ public abstract class AccessDirection implements Direction {
findInY = true;
}
}
if (findInX && findInY) {
break;
}
}
if (findInX && findInY) {
break;
}
}
setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point);
@ -124,7 +125,7 @@ public abstract class AccessDirection implements Direction {
}
private WAbsoluteLayout getLayout(final FormDesigner designer) {
private WAbsoluteLayout getLayout(final FormDesigner designer){
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(
designer.getTarget().getContainer());
WAbsoluteLayout layout;
@ -156,52 +157,50 @@ public abstract class AccessDirection implements Direction {
return;
}
//设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。
if (rec.height == MINHEIGHT) {
if(rec.height == MINHEIGHT){
ymin = rec.y;
}
if (rec.height == MINHEIGHT - 1) {
if(rec.height == MINHEIGHT - 1){
ymin = ymin == rec.y ? rec.y : rec.y - 1;
}
if (rec.height < MINHEIGHT) {
if(rec.height < MINHEIGHT){
rec.height = MINHEIGHT;
rec.y = ymin;
}
// 增加下宽度也设最小为21
if (rec.width == MINWIDTH) {
xmin = rec.x;
xmin = rec.x;
}
if (rec.width == MINWIDTH - 1) {
xmin = xmin == rec.x ? rec.x : rec.x - 1;
if(rec.width == MINWIDTH - 1){
xmin = xmin == rec.x ? rec.x : rec.x - 1;
}
if (rec.width < MINWIDTH) {
rec.width = MINWIDTH;
rec.x = xmin;
rec.width = MINWIDTH;
rec.x = xmin;
}
}
/**
* 更新鼠标指针形状
*
* @param formEditor 设计界面组件
*/
public void updateCursor(FormDesigner formEditor) {
// 调用位置枚举的多态方法getCursor获取鼠标形状
int type = getCursor();
if (type != formEditor.getCursor().getType()) {
// 设置当前形状
formEditor.setCursor(Cursor.getPredefinedCursor(type));
}
}
/**
* 生成组件备用的bound
*
* @param formEditor 设计界面组件
*/
public void backupBounds(FormDesigner formEditor) {
formEditor.getSelectionModel().getSelection().backupBounds();
}
/**
* 更新鼠标指针形状
* @param formEditor 设计界面组件
*/
public void updateCursor(FormDesigner formEditor) {
// 调用位置枚举的多态方法getCursor获取鼠标形状
int type = getCursor();
if (type != formEditor.getCursor().getType()) {
// 设置当前形状
formEditor.setCursor(Cursor.getPredefinedCursor(type));
}
}
/**
* 生成组件备用的bound
* @param formEditor 设计界面组件
*/
public void backupBounds(FormDesigner formEditor) {
formEditor.getSelectionModel().getSelection().backupBounds();
}
}

280
designer_form/src/com/fr/design/designer/beans/models/AddingModel.java

@ -1,141 +1,141 @@
package com.fr.design.designer.beans.models;
import java.awt.Rectangle;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.general.ComparatorUtils;
/**
* 添加状态下的model
*/
public class AddingModel {
// 当前要添加的组件
private XCreator creator;
// 记录当前鼠标的位置信息
private int currentX;
private int currentY;
private boolean added;
public AddingModel(FormDesigner designer, XCreator xCreator) {
String creatorName = getXCreatorName(designer, xCreator);
this.creator = xCreator;
instantiateCreator(designer, creatorName);
// 初始的时候隐藏该组件的图标
currentY = -this.creator.getWidth();
currentX = -this.creator.getHeight();
}
/**
* 待说明
*
* @param designer 设计器
* @param creatorName 组件名
*/
public void instantiateCreator(FormDesigner designer, String creatorName) {
creator.toData().setWidgetName(creatorName);
ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
adapter.initialize();
creator.addNotify();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
public AddingModel(XCreator xCreator, int x, int y) {
this.creator = xCreator;
this.creator.backupCurrentSize();
this.creator.backupParent();
this.creator.setSize(xCreator.initEditorSize());
currentX = x - (xCreator.getWidth() / 2);
currentY = y - (xCreator.getHeight() / 2);
}
/**
* 隐藏当前组件的图标
*/
public void reset() {
currentX = -this.creator.getWidth();
currentY = -this.creator.getHeight();
}
public String getXCreatorName(FormDesigner designer, XCreator x) {
String def = x.createDefaultName();
if (x.acceptType(XWParameterLayout.class)) {
return def;
}
int i = 0;
while (designer.getTarget().isNameExist(def + i)) {
i++;
}
return def + i;
}
public int getCurrentX() {
return currentX;
}
public int getCurrentY() {
return currentY;
}
/**
* 移动组件图标到鼠标事件发生的位置
*
* @param x 坐标
* @param y 坐标
*/
public void moveTo(int x, int y) {
currentX = x - (this.creator.getWidth() / 2);
currentY = y - (this.creator.getHeight() / 2);
}
public XCreator getXCreator() {
return this.creator;
}
/**
* 当前组件是否已经添加到某个容器中
*
* @return 是返回true
*/
public boolean isCreatorAdded() {
return added;
}
/**
* 加入容器
*
* @param designer 设计器
* @param container 容器
* @param x 坐标
* @param y 坐标
* @return 成功返回true
*/
public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) {
//考虑不同布局嵌套的情况,获取顶层容器
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)) {
container = xLayoutContainer;
}
Rectangle rect = ComponentUtils.getRelativeBounds(container);
if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) {
added = container.getLayoutAdapter().addBean(creator,
x + designer.getArea().getHorizontalValue(),
y + designer.getArea().getVerticalValue());
return added;
}
added = container.getLayoutAdapter().addBean(creator,
x + designer.getArea().getHorizontalValue() - rect.x,
y + designer.getArea().getVerticalValue() - rect.y);
return added;
}
package com.fr.design.designer.beans.models;
import java.awt.Rectangle;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.general.ComparatorUtils;
/**
* 添加状态下的model
*/
public class AddingModel {
// 当前要添加的组件
private XCreator creator;
// 记录当前鼠标的位置信息
private int currentX;
private int currentY;
private boolean added;
public AddingModel(FormDesigner designer, XCreator xCreator) {
String creatorName = getXCreatorName(designer, xCreator);
this.creator = xCreator;
instantiateCreator(designer, creatorName);
// 初始的时候隐藏该组件的图标
currentY = -this.creator.getWidth();
currentX = -this.creator.getHeight();
}
/**
* 待说明
*
* @param designer 设计器
* @param creatorName 组件名
*/
public void instantiateCreator(FormDesigner designer, String creatorName) {
creator.toData().setWidgetName(creatorName);
ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
adapter.initialize();
creator.addNotify();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
public AddingModel(XCreator xCreator, int x, int y) {
this.creator = xCreator;
this.creator.backupCurrentSize();
this.creator.backupParent();
this.creator.setSize(xCreator.initEditorSize());
currentX = x - (xCreator.getWidth() / 2);
currentY = y - (xCreator.getHeight() / 2);
}
/**
* 隐藏当前组件的图标
*/
public void reset() {
currentX = -this.creator.getWidth();
currentY = -this.creator.getHeight();
}
public String getXCreatorName(FormDesigner designer, XCreator x) {
String def = x.createDefaultName();
if (x.acceptType(XWParameterLayout.class)) {
return def;
}
int i = 0;
while (designer.getTarget().isNameExist(def + i)) {
i++;
}
return def + i;
}
public int getCurrentX() {
return currentX;
}
public int getCurrentY() {
return currentY;
}
/**
* 移动组件图标到鼠标事件发生的位置
*
* @param x 坐标
* @param y 坐标
*/
public void moveTo(int x, int y) {
currentX = x - (this.creator.getWidth() / 2);
currentY = y - (this.creator.getHeight() / 2);
}
public XCreator getXCreator() {
return this.creator;
}
/**
* 当前组件是否已经添加到某个容器中
*
* @return 是返回true
*/
public boolean isCreatorAdded() {
return added;
}
/**
* 加入容器
*
* @param designer 设计器
* @param container 容器
* @param x 坐标
* @param y 坐标
* @return 成功返回true
*/
public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) {
//考虑不同布局嵌套的情况,获取顶层容器
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)) {
container = xLayoutContainer;
}
Rectangle rect = ComponentUtils.getRelativeBounds(container);
if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) {
added = container.getLayoutAdapter().addBean(creator,
x + designer.getArea().getHorizontalValue(),
y + designer.getArea().getVerticalValue());
return added;
}
added = container.getLayoutAdapter().addBean(creator,
x + designer.getArea().getHorizontalValue() - rect.x,
y + designer.getArea().getVerticalValue() - rect.y);
return added;
}
}

950
designer_form/src/com/fr/design/designer/beans/models/StateModel.java

@ -1,476 +1,476 @@
package com.fr.design.designer.beans.models;
import com.fr.design.beans.location.Absorptionline;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.creator.*;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.ComponentUtils;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/**
* 普通模式下的状态model
*/
public class StateModel {
// 对应的selection model
private SelectionModel selectionModel;
// 当前鼠标进入拖拽区域的位置类型
private Direction driection;
// 当前拖拽的起始位置
private int currentX;
private int currentY;
//拖拽组件原始位置大小备份
private Rectangle selectedPositionBackup;
private Point startPoint = new Point();
private Point currentPoint = new Point();
private Absorptionline lineInX;
private Absorptionline lineInY;
//等距线
private Absorptionline lineEquidistant;
// 当前是否处于拖拽选择状态
private boolean selecting;
private boolean dragging;
private boolean addable;
private FormDesigner designer;
public StateModel(FormDesigner designer) {
this.designer = designer;
selectionModel = designer.getSelectionModel();
}
/**
* 返回direction
*
* @return direction方向
*/
public Direction getDirection() {
return driection;
}
/**
* 是否有组件正被选中
*
* @return true 如果至少一个组件被选中
*/
public boolean isSelecting() {
return selecting;
}
/**
* 是否能拖拽
*
* @return 非outer且选中为空
*/
public boolean dragable() {
return ((driection != Location.outer) && !selecting);
}
/**
* 拖拽中是否可以转换为添加模式
* 如果拖拽组件只有一个鼠标当前所在位置的最底层表单容器与这个组件的容器不同
* 如果拖拽组件为多个鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外还必须是绝对定位布局
*/
private void checkAddable(MouseEvent e) {
addable = false;
designer.setPainter(null);
if (driection != Location.inner) {
return;
}
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator();
Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator);
if (creatorContainer != null && creatorContainer != container
&& (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) {
HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
designer.setPainter(painter);
if (painter != null) {
Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect);
painter.setHotspot(new Point(e.getX(), e.getY()));
painter.setCreator(creator);
}
addable = true;
}
}
/**
* @param container 容器
* @param mouseX 鼠标释放位置X
* @param mouseY 鼠标释放位置Y
* @return 是否成功
*/
private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) {
LayoutAdapter adapter = container.getLayoutAdapter();
Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container);
if (selectionModel.getSelection().size() == 1) {
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(),
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
}
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
adapter.addBean(creator,
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
}
return true;
}
/**
* @param mouseReleasedX 鼠标释放位置X
* @param mouseReleasedY 鼠标释放位置Y
*/
private void adding(int mouseReleasedX, int mouseReleasedY) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators());
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
boolean success = false;
if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件
success = addBean(container, mouseReleasedX, mouseReleasedY);
}
if (success) {
FormSelectionUtils.rebuildSelection(designer);
designer.getEditListenerTable().fireCreatorModified(
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED);
} else {
selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer);
Toolkit.getDefaultToolkit().beep();
}
// 取消提示
designer.setPainter(null);
}
/**
* 是否拖拽
*
* @return dragging状态
*/
public boolean isDragging() {
return dragging;
}
/**
* 是否可以开始画线
*
* @return startPoint不为空返回true
*/
public boolean prepareForDrawLining() {
return startPoint != null;
}
/**
* 设置开始位置
*
* @param p point位置
*/
public void setStartPoint(Point p) {
this.startPoint = p;
}
/**
* 返回开始位置
*
* @return 点位置
*/
public Point getStartPoint() {
return startPoint;
}
/**
* 返回当前点位置
*
* @return 点位置
*/
public Point getEndPoint() {
return currentPoint;
}
/**
* 当前选中组件
*
* @param e 鼠标事件
*/
public void startSelecting(MouseEvent e) {
selecting = true;
selectionModel.setHotspotBounds(new Rectangle());
currentX = getMouseXY(e).x;
currentY = getMouseXY(e).y;
}
/**
* 当前鼠标的xy
*
* @param e 鼠标事件
*/
public void startResizing(MouseEvent e) {
if (!selectionModel.getSelection().isEmpty()) {
driection.backupBounds(designer);
}
currentX = getMouseXY(e).x;
currentY = getMouseXY(e).y;
}
/**
* 起始点开始DrawLine
*
* @param p 点位置
*/
public void startDrawLine(Point p) {
this.startPoint = p;
if (p != null) {
try {
designer.setCursor(XConnector.connectorCursor);
} catch (Exception e) {
}
} else {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
/**
* 鼠标释放时所在的区域及圈中的组件
*
* @param e 鼠标事件
*/
public void selectCreators(MouseEvent e) {
int x = getMouseXY(e).x;
int y = getMouseXY(e).y;
Rectangle bounds = createCurrentBounds(x, y);
if ((x != currentX) || (y != currentY)) {
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent()));
}
selectionModel.setHotspotBounds(null);
}
/**
* 画所在区域线
*
* @param e 鼠标事件
*/
public void drawLine(MouseEvent e) {
designer.getDrawLineHelper().setDrawLine(true);
Point p = designer.getDrawLineHelper().getNearWidgetPoint(e);
if (p != null) {
currentPoint = p;
} else {
currentPoint.x = e.getX() + designer.getArea().getHorizontalValue();
currentPoint.y = e.getY() + designer.getArea().getVerticalValue();
}
}
private Rectangle createCurrentBounds(int x, int y) {
Rectangle bounds = new Rectangle();
bounds.x = Math.min(x, currentX);
bounds.y = Math.min(y, currentY);
bounds.width = Math.max(x, currentX) - bounds.x;
bounds.height = Math.max(y, currentY) - bounds.y;
return bounds;
}
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) {
ArrayList<XCreator> creators = new ArrayList<>();
if (!root.isVisible() && !designer.isRoot(root)) {
return creators;
}
if (root instanceof XLayoutContainer) {
XLayoutContainer container = (XLayoutContainer) root;
int count = container.getXCreatorCount();
Rectangle clipped = new Rectangle(selection);
for (int i = count - 1; i >= 0; i--) {
XCreator child = container.getXCreator(i);
if (selection.contains(child.getBounds())) {
creators.add(child);
} else {
clipped.x = selection.x - child.getX();
clipped.y = selection.y - child.getY();
creators.addAll(getHotspotCreators(clipped, child));
}
}
}
return creators;
}
/**
* 重置model
*/
public void resetModel() {
dragging = false;
selecting = false;
}
/**
* 重置
*/
public void reset() {
driection = Location.outer;
dragging = false;
selecting = false;
}
/**
* 取消拖拽
*/
public void draggingCancel() {
designer.repaint();
reset();
}
/**
* 设置可拉伸方向
*
* @param dir 拉伸方向
*/
public void setDirection(Direction dir) {
if (driection != dir) {
this.driection = dir;
driection.updateCursor(designer);
}
}
/**
* x吸附线赋值
*
* @param line 线
*/
public void setXAbsorptionline(Absorptionline line) {
this.lineInX = line;
}
/**
* y吸附线赋值
*
* @param line 线
*/
public void setYAbsorptionline(Absorptionline line) {
this.lineInY = line;
}
/**
* 等距线赋值
*
* @param line 线
*/
public void setEquidistantLine(Absorptionline line) {
this.lineEquidistant = line;
}
/**
* 画吸附线
*
* @param g Graphics类
*/
public void paintAbsorptionline(Graphics g) {
if (lineInX != null) {
lineInX.paint(g, designer.getArea());
}
if (lineInY != null) {
lineInY.paint(g, designer.getArea());
}
if (lineEquidistant != null) {
lineEquidistant.paint(g, designer.getArea());
}
}
/**
* 拖拽
*
* @param e 鼠标事件
*/
public void dragging(MouseEvent e) {
//进入dragging状态时备份组件大小和位置
if (!dragging) {
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds();
}
checkAddable(e);
setDependLinePainter(e);
driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer);
this.dragging = true;
}
// 拖拽时画依附线用到的painter
private void setDependLinePainter(MouseEvent e) {
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator();
HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
designer.setPainter(painter);
if (painter != null) {
painter.setHotspot(new Point(e.getX(), e.getY()));
painter.setCreator(creator);
}
}
/**
* 释放捕获
*
* @param e 鼠标事件
*/
public void releaseDragging(MouseEvent e) {
this.dragging = false;
if (addable) {
adding(e.getX(), e.getY());
} else if (!selectionModel.getSelection().isEmpty()) {
selectionModel.releaseDragging();
}
designer.repaint();
}
/**
* 改变选择区域
*
* @param e 鼠标事件
*/
public void changeSelection(MouseEvent e) {
Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y);
selectionModel.setHotspotBounds(bounds);
}
/**
* 返回鼠标所在的xy 考虑滚动条的值
*
* @param e 鼠标事件
* @return xy值
*/
public Point getMouseXY(MouseEvent e) {
Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY()
+ designer.getArea().getVerticalValue());
return p1;
}
package com.fr.design.designer.beans.models;
import com.fr.design.beans.location.Absorptionline;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.creator.*;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.ComponentUtils;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/**
* 普通模式下的状态model
*/
public class StateModel {
// 对应的selection model
private SelectionModel selectionModel;
// 当前鼠标进入拖拽区域的位置类型
private Direction driection;
// 当前拖拽的起始位置
private int currentX;
private int currentY;
//拖拽组件原始位置大小备份
private Rectangle selectedPositionBackup;
private Point startPoint = new Point();
private Point currentPoint = new Point();
private Absorptionline lineInX;
private Absorptionline lineInY;
//等距线
private Absorptionline lineEquidistant;
// 当前是否处于拖拽选择状态
private boolean selecting;
private boolean dragging;
private boolean addable;
private FormDesigner designer;
public StateModel(FormDesigner designer) {
this.designer = designer;
selectionModel = designer.getSelectionModel();
}
/**
* 返回direction
*
* @return direction方向
*/
public Direction getDirection() {
return driection;
}
/**
* 是否有组件正被选中
*
* @return true 如果至少一个组件被选中
*/
public boolean isSelecting() {
return selecting;
}
/**
* 是否能拖拽
*
* @return 非outer且选中为空
*/
public boolean dragable() {
return ((driection != Location.outer) && !selecting);
}
/**
* 拖拽中是否可以转换为添加模式
* 如果拖拽组件只有一个鼠标当前所在位置的最底层表单容器与这个组件的容器不同
* 如果拖拽组件为多个鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外还必须是绝对定位布局
*/
private void checkAddable(MouseEvent e) {
addable = false;
designer.setPainter(null);
if (driection != Location.inner) {
return;
}
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator();
Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator);
if (creatorContainer != null && creatorContainer != container
&& (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) {
HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
designer.setPainter(painter);
if (painter != null) {
Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect);
painter.setHotspot(new Point(e.getX(), e.getY()));
painter.setCreator(creator);
}
addable = true;
}
}
/**
* @param container 容器
* @param mouseX 鼠标释放位置X
* @param mouseY 鼠标释放位置Y
* @return 是否成功
*/
private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) {
LayoutAdapter adapter = container.getLayoutAdapter();
Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container);
if (selectionModel.getSelection().size() == 1) {
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(),
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
}
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
adapter.addBean(creator,
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
}
return true;
}
/**
* @param mouseReleasedX 鼠标释放位置X
* @param mouseReleasedY 鼠标释放位置Y
*/
private void adding(int mouseReleasedX, int mouseReleasedY) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators());
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
boolean success = false;
if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件
success = addBean(container, mouseReleasedX, mouseReleasedY);
}
if (success) {
FormSelectionUtils.rebuildSelection(designer);
designer.getEditListenerTable().fireCreatorModified(
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED);
} else {
selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer);
Toolkit.getDefaultToolkit().beep();
}
// 取消提示
designer.setPainter(null);
}
/**
* 是否拖拽
*
* @return dragging状态
*/
public boolean isDragging() {
return dragging;
}
/**
* 是否可以开始画线
*
* @return startPoint不为空返回true
*/
public boolean prepareForDrawLining() {
return startPoint != null;
}
/**
* 设置开始位置
*
* @param p point位置
*/
public void setStartPoint(Point p) {
this.startPoint = p;
}
/**
* 返回开始位置
*
* @return 点位置
*/
public Point getStartPoint() {
return startPoint;
}
/**
* 返回当前点位置
*
* @return 点位置
*/
public Point getEndPoint() {
return currentPoint;
}
/**
* 当前选中组件
*
* @param e 鼠标事件
*/
public void startSelecting(MouseEvent e) {
selecting = true;
selectionModel.setHotspotBounds(new Rectangle());
currentX = getMouseXY(e).x;
currentY = getMouseXY(e).y;
}
/**
* 当前鼠标的xy
*
* @param e 鼠标事件
*/
public void startResizing(MouseEvent e) {
if (!selectionModel.getSelection().isEmpty()) {
driection.backupBounds(designer);
}
currentX = getMouseXY(e).x;
currentY = getMouseXY(e).y;
}
/**
* 起始点开始DrawLine
*
* @param p 点位置
*/
public void startDrawLine(Point p) {
this.startPoint = p;
if (p != null) {
try {
designer.setCursor(XConnector.connectorCursor);
} catch (Exception e) {
}
} else {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
/**
* 鼠标释放时所在的区域及圈中的组件
*
* @param e 鼠标事件
*/
public void selectCreators(MouseEvent e) {
int x = getMouseXY(e).x;
int y = getMouseXY(e).y;
Rectangle bounds = createCurrentBounds(x, y);
if ((x != currentX) || (y != currentY)) {
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent()));
}
selectionModel.setHotspotBounds(null);
}
/**
* 画所在区域线
*
* @param e 鼠标事件
*/
public void drawLine(MouseEvent e) {
designer.getDrawLineHelper().setDrawLine(true);
Point p = designer.getDrawLineHelper().getNearWidgetPoint(e);
if (p != null) {
currentPoint = p;
} else {
currentPoint.x = e.getX() + designer.getArea().getHorizontalValue();
currentPoint.y = e.getY() + designer.getArea().getVerticalValue();
}
}
private Rectangle createCurrentBounds(int x, int y) {
Rectangle bounds = new Rectangle();
bounds.x = Math.min(x, currentX);
bounds.y = Math.min(y, currentY);
bounds.width = Math.max(x, currentX) - bounds.x;
bounds.height = Math.max(y, currentY) - bounds.y;
return bounds;
}
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) {
ArrayList<XCreator> creators = new ArrayList<>();
if (!root.isVisible() && !designer.isRoot(root)) {
return creators;
}
if (root instanceof XLayoutContainer) {
XLayoutContainer container = (XLayoutContainer) root;
int count = container.getXCreatorCount();
Rectangle clipped = new Rectangle(selection);
for (int i = count - 1; i >= 0; i--) {
XCreator child = container.getXCreator(i);
if (selection.contains(child.getBounds())) {
creators.add(child);
} else {
clipped.x = selection.x - child.getX();
clipped.y = selection.y - child.getY();
creators.addAll(getHotspotCreators(clipped, child));
}
}
}
return creators;
}
/**
* 重置model
*/
public void resetModel() {
dragging = false;
selecting = false;
}
/**
* 重置
*/
public void reset() {
driection = Location.outer;
dragging = false;
selecting = false;
}
/**
* 取消拖拽
*/
public void draggingCancel() {
designer.repaint();
reset();
}
/**
* 设置可拉伸方向
*
* @param dir 拉伸方向
*/
public void setDirection(Direction dir) {
if (driection != dir) {
this.driection = dir;
driection.updateCursor(designer);
}
}
/**
* x吸附线赋值
*
* @param line 线
*/
public void setXAbsorptionline(Absorptionline line) {
this.lineInX = line;
}
/**
* y吸附线赋值
*
* @param line 线
*/
public void setYAbsorptionline(Absorptionline line) {
this.lineInY = line;
}
/**
* 等距线赋值
*
* @param line 线
*/
public void setEquidistantLine(Absorptionline line) {
this.lineEquidistant = line;
}
/**
* 画吸附线
*
* @param g Graphics类
*/
public void paintAbsorptionline(Graphics g) {
if (lineInX != null) {
lineInX.paint(g, designer.getArea());
}
if (lineInY != null) {
lineInY.paint(g, designer.getArea());
}
if (lineEquidistant != null) {
lineEquidistant.paint(g, designer.getArea());
}
}
/**
* 拖拽
*
* @param e 鼠标事件
*/
public void dragging(MouseEvent e) {
//进入dragging状态时备份组件大小和位置
if (!dragging) {
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds();
}
checkAddable(e);
setDependLinePainter(e);
driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer);
this.dragging = true;
}
// 拖拽时画依附线用到的painter
private void setDependLinePainter(MouseEvent e) {
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator();
HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
designer.setPainter(painter);
if (painter != null) {
painter.setHotspot(new Point(e.getX(), e.getY()));
painter.setCreator(creator);
}
}
/**
* 释放捕获
*
* @param e 鼠标事件
*/
public void releaseDragging(MouseEvent e) {
this.dragging = false;
if (addable) {
adding(e.getX(), e.getY());
} else if (!selectionModel.getSelection().isEmpty()) {
selectionModel.releaseDragging();
}
designer.repaint();
}
/**
* 改变选择区域
*
* @param e 鼠标事件
*/
public void changeSelection(MouseEvent e) {
Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y);
selectionModel.setHotspotBounds(bounds);
}
/**
* 返回鼠标所在的xy 考虑滚动条的值
*
* @param e 鼠标事件
* @return xy值
*/
public Point getMouseXY(MouseEvent e) {
Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY()
+ designer.getArea().getVerticalValue());
return p1;
}
}

190
designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java

@ -1,96 +1,96 @@
package com.fr.design.designer.beans.painters;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Stroke;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.general.Inter;
public abstract class AbstractPainter implements HoverPainter {
protected Point hotspot;
protected Rectangle hotspot_bounds;
protected XLayoutContainer container;
protected XCreator creator;
/**
* 构造函数
*
* @param container 容器
*/
public AbstractPainter(XLayoutContainer container) {
this.container = container;
}
@Override
public void setHotspot(Point p) {
hotspot = p;
}
/**
* 画初始区域
*
* @param g 画图类
* @param startX 起始x位置
* @param startY 起始y位置
*/
public void paint(Graphics g, int startX, int startY) {
if (hotspot_bounds != null) {
drawHotspot(g, hotspot_bounds.x, hotspot_bounds.y, hotspot_bounds.width, hotspot_bounds.height, Color.lightGray, true, false);
}
}
/**
* 设置边界
*
* @param rect 位置
*/
@Override
public void setRenderingBounds(Rectangle rect) {
hotspot_bounds = rect;
}
@Override
public void setCreator(XCreator component) {
this.creator = component;
}
protected void drawHotspot(Graphics g, int x, int y, int width, int height, boolean accept) {
Color bColor = accept ? XCreatorConstants.LAYOUT_HOTSPOT_COLOR : XCreatorConstants.LAYOUT_FORBIDDEN_COLOR;
drawHotspot(g, x, y, width, height, bColor, accept, false);
}
/**
* 自适应布局那边渲染提示要画整个背景不是画边框
*/
protected void drawRegionBackground(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept) {
drawHotspot(g, x, y, width, height, bColor, accept, true);
}
protected void drawHotspot(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept, boolean drawBackground) {
Graphics2D g2d = (Graphics2D) g;
Color color = g2d.getColor();
Stroke backup = g2d.getStroke();
// 设置线条的样式
g2d.setStroke(XCreatorConstants.STROKE);
g2d.setColor(bColor);
if (!accept) {
g2d.drawString(Inter.getLocText("Cannot-Add_To_This_Area") + "!", x + width / 3, y + height / 2);
} else if (drawBackground) {
g2d.fillRect(x, y, width, height);
} else {
g2d.drawRect(x, y, width, height);
}
g2d.setStroke(backup);
g2d.setColor(color);
}
package com.fr.design.designer.beans.painters;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Stroke;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.general.Inter;
public abstract class AbstractPainter implements HoverPainter {
protected Point hotspot;
protected Rectangle hotspot_bounds;
protected XLayoutContainer container;
protected XCreator creator;
/**
* 构造函数
*
* @param container 容器
*/
public AbstractPainter(XLayoutContainer container) {
this.container = container;
}
@Override
public void setHotspot(Point p) {
hotspot = p;
}
/**
* 画初始区域
*
* @param g 画图类
* @param startX 起始x位置
* @param startY 起始y位置
*/
public void paint(Graphics g, int startX, int startY) {
if (hotspot_bounds != null) {
drawHotspot(g, hotspot_bounds.x, hotspot_bounds.y, hotspot_bounds.width, hotspot_bounds.height, Color.lightGray, true, false);
}
}
/**
* 设置边界
*
* @param rect 位置
*/
@Override
public void setRenderingBounds(Rectangle rect) {
hotspot_bounds = rect;
}
@Override
public void setCreator(XCreator component) {
this.creator = component;
}
protected void drawHotspot(Graphics g, int x, int y, int width, int height, boolean accept) {
Color bColor = accept ? XCreatorConstants.LAYOUT_HOTSPOT_COLOR : XCreatorConstants.LAYOUT_FORBIDDEN_COLOR;
drawHotspot(g, x, y, width, height, bColor, accept, false);
}
/**
* 自适应布局那边渲染提示要画整个背景不是画边框
*/
protected void drawRegionBackground(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept) {
drawHotspot(g, x, y, width, height, bColor, accept, true);
}
protected void drawHotspot(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept, boolean drawBackground) {
Graphics2D g2d = (Graphics2D) g;
Color color = g2d.getColor();
Stroke backup = g2d.getStroke();
// 设置线条的样式
g2d.setStroke(XCreatorConstants.STROKE);
g2d.setColor(bColor);
if (!accept) {
g2d.drawString(Inter.getLocText("Cannot-Add_To_This_Area") + "!", x + width / 3, y + height / 2);
} else if (drawBackground) {
g2d.fillRect(x, y, width, height);
} else {
g2d.drawRect(x, y, width, height);
}
g2d.setStroke(backup);
g2d.setColor(color);
}
}

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

@ -10,11 +10,9 @@ import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.widget.editors.BooleanEditor;
import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor;
import com.fr.design.mainframe.widget.editors.PaddingMarginEditor;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer;
import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.FormProvider;
@ -104,7 +102,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
.setI18NName(Inter.getLocText("FR-Layout_Padding"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("showToolBar", this.data.getClass()).setEditorClass(BooleanEditor.class)
new CRPropertyDescriptor("toolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class)
.setI18NName(Inter.getLocText("Form-EC_toolbar"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
};

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

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

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) {
super(t, xCardSwitchButton);
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

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) {
super(t, xCardSwitchButton);
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

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) {
super(t, xCardSwitchButton);
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

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

@ -3,10 +3,6 @@
*/
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.ComponentAdapter;
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.mainframe.EditingMouseListener;
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.cardlayout.WCardMainBorderLayout;
import com.fr.general.IOUtils;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.general.Inter;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
/**
* card布局主体框架
*

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

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

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

@ -25,7 +25,6 @@ public class FormSelectionUtils {
//组件重命名后缀
private static final String POSTFIX = "_c";
private FormSelectionUtils() {
}
@ -134,8 +133,10 @@ public class FormSelectionUtils {
boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth();
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);
y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y;
boolean isEdge = (x - DELAY_X_Y == container.getWidth() - copiedCreator.getWidth() / 2 - xoffset);
if (xOut) {
if (isEdge) {
//向左偏移

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

@ -259,8 +259,11 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
xCreator = designer.getRootComponent();
}
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) {

2
designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java

@ -35,8 +35,6 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
WLayout wl = (WLayout) template.getContainer().getWidget(i);
widgetCount += wl.getWidgetCount();
}
int a = 1;
int b = 2;
return widgetCount;
}
}

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

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

Loading…
Cancel
Save