Browse Source

Merge branch 'feature/9.0' of ssh://cloud.finedevelop.com:7999/~hzzz/design into feature/9.0

hzzz 8 years ago
parent
commit
22f9171102
  1. 6
      designer/src/com/fr/design/actions/edit/DeleteAction.java
  2. 10
      designer/src/com/fr/design/actions/edit/order/BringFloatElementForwardAction.java
  3. 13
      designer/src/com/fr/design/actions/edit/order/BringFloatElementToFrontAction.java
  4. 10
      designer/src/com/fr/design/actions/edit/order/SendFloatElementBackwardAction.java
  5. 11
      designer/src/com/fr/design/actions/edit/order/SendFloatElementToBackAction.java
  6. 19
      designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java
  7. 4
      designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java
  8. 7
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  9. 8
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  10. 8
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  11. 77
      designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  12. 58
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  13. 6
      designer/src/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java
  14. 10
      designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java
  15. 9
      designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java
  16. 104
      designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  17. 16
      designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  18. 32
      designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java
  19. 18
      designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  20. 2
      designer/src/com/fr/design/widget/WidgetEventPane.java
  21. 33
      designer/src/com/fr/grid/selection/FloatSelection.java
  22. 24
      designer_base/src/com/fr/design/DesignerEnvManager.java
  23. 23
      designer_base/src/com/fr/design/actions/file/PreferencePane.java
  24. 2
      designer_base/src/com/fr/design/constants/UIConstants.java
  25. 4
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  26. 59
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  27. 10
      designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
  28. 2
      designer_base/src/com/fr/design/file/HistoryTemplateListPane.java
  29. 5
      designer_base/src/com/fr/design/file/MutilTempalteTabPane.java
  30. 6
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  31. 274
      designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java
  32. 237
      designer_base/src/com/fr/design/gui/imenu/UIMenu.java
  33. 2
      designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java
  34. 4
      designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java
  35. 24
      designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java
  36. 2
      designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java
  37. 9
      designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java
  38. BIN
      designer_base/src/com/fr/design/images/control/clear.png
  39. BIN
      designer_base/src/com/fr/design/images/control/icon_thumb_normal.png
  40. BIN
      designer_base/src/com/fr/design/images/control/remove.png
  41. BIN
      designer_base/src/com/fr/design/images/control/to_bottom.png
  42. BIN
      designer_base/src/com/fr/design/images/control/to_top.png
  43. 15
      designer_base/src/com/fr/design/locale/designer.properties
  44. 15
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  45. 15
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  46. 15
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  47. 15
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  48. 15
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  49. 2
      designer_base/src/com/fr/design/mainframe/DesignerFrame.java
  50. 50
      designer_base/src/com/fr/design/mainframe/JSliderPane.java
  51. 6
      designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java
  52. 1
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  53. 14
      designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  54. 42
      designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java
  55. 99
      designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  56. 37
      designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java
  57. 29
      designer_base/src/com/fr/design/mainframe/widget/wrappers/TemplateStyleWrapper.java
  58. 12
      designer_base/src/com/fr/design/menu/MenuDef.java
  59. 2
      designer_base/src/com/fr/design/utils/ThemeUtils.java
  60. 37
      designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java
  61. 24
      designer_base/src/com/fr/design/widget/WidgetBoundsPaneFactory.java
  62. 83
      designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java
  63. 59
      designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java
  64. 60
      designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java
  65. 59
      designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java
  66. 59
      designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java
  67. 4
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  68. 21
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  69. 2
      designer_form/src/com/fr/design/designer/beans/events/DesignerEvent.java
  70. 9
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  71. 3
      designer_form/src/com/fr/design/designer/beans/painters/FRBorderLayoutPainter.java
  72. 8
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  73. 37
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  74. 3
      designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java
  75. 9
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  76. 4
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  77. 3
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  78. 4
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  79. 25
      designer_form/src/com/fr/design/designer/creator/XWHorizontalBoxLayout.java
  80. 5
      designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java
  81. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  82. 113
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  83. 26
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  84. 82
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  85. 239
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  86. 48
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  87. 23
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  88. 12
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  89. 24
      designer_form/src/com/fr/design/form/layout/FRFlowLayout.java
  90. 36
      designer_form/src/com/fr/design/form/layout/FRHorizontalLayout.java
  91. 34
      designer_form/src/com/fr/design/form/layout/FRVerticalLayout.java
  92. 5
      designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java
  93. 77
      designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java
  94. 611
      designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java
  95. 210
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  96. 23
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  97. 50
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  98. 44
      designer_form/src/com/fr/design/mainframe/FormDesignerUI.java
  99. 93
      designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java
  100. 12
      designer_form/src/com/fr/design/mainframe/FormSelection.java
  101. Some files were not shown because too many files have changed in this diff Show More

6
designer/src/com/fr/design/actions/edit/DeleteAction.java

@ -8,6 +8,9 @@ import com.fr.design.actions.ElementCaseAction;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
import javax.swing.*;
import java.awt.event.KeyEvent;
/**
* Delete Row, Column or FloatElement..
*/
@ -18,10 +21,11 @@ public class DeleteAction extends ElementCaseAction {
public DeleteAction(ElementCasePane t) {
super(t);
this.setName(Inter.getLocText("M_Edit-Delete") + "...");
this.setName(Inter.getLocText("M_Edit-Delete"));
this.setMnemonic('D');
//Richie:删除菜单图标
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
}
@Override

10
designer/src/com/fr/design/actions/edit/order/BringFloatElementForwardAction.java

@ -9,6 +9,11 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.ElementCase;
import javax.swing.*;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* Bring FloatElement forward.
*/
@ -21,8 +26,9 @@ public class BringFloatElementForwardAction extends AbstractFloatElementOrderAct
this.setName(Inter.getLocText("M_Edit-Bring_Forward"));
this.setMnemonic('F');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/bringForward.png"));
}
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER));
}
@Override
public void orderWithSelectedFloatElement(ElementCase report,

13
designer/src/com/fr/design/actions/edit/order/BringFloatElementToFrontAction.java

@ -9,6 +9,12 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.ElementCase;
import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* Bring FloatElement to front.
*/
@ -20,9 +26,10 @@ public class BringFloatElementToFrontAction extends AbstractFloatElementOrderAct
super(t);
this.setName(Inter.getLocText("M_Edit-Bring_to_Front"));
this.setMnemonic('t');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/bringToFront.png"));
}
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_top.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK));
}
@Override
public void orderWithSelectedFloatElement(ElementCase report,

10
designer/src/com/fr/design/actions/edit/order/SendFloatElementBackwardAction.java

@ -9,6 +9,11 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.ElementCase;
import javax.swing.*;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* Send FloatElement backward.
*/
@ -21,8 +26,9 @@ public class SendFloatElementBackwardAction extends AbstractFloatElementOrderAct
this.setName(Inter.getLocText("M_Edit-Send_Backward"));
this.setMnemonic('B');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/sendBackward.png"));
}
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER));
}
@Override
public void orderWithSelectedFloatElement(ElementCase report,

11
designer/src/com/fr/design/actions/edit/order/SendFloatElementToBackAction.java

@ -9,6 +9,12 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.ElementCase;
import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* Send FloatElement to back.
*/
@ -21,8 +27,9 @@ public class SendFloatElementToBackAction extends AbstractFloatElementOrderActio
this.setName(Inter.getLocText("M_Edit-Send_to_Back"));
this.setMnemonic('K');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/sendToBack.png"));
}
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_bottom.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK));
}
@Override
public void orderWithSelectedFloatElement(ElementCase report,

19
designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java

@ -49,7 +49,7 @@ public class DeprecatedActionManager {
*/
public static UIMenu getClearMenu(ElementCasePane ePane) {
UIMenu clearMenu = new UIMenu(Inter.getLocText("M_Edit-Clear"));
clearMenu.setIcon(UIConstants.BLACK_ICON);
clearMenu.setIcon(BaseUtils.readIcon("/com/fr/design/images/control/clear.png"));
clearMenu.setMnemonic('a');
ClearAction ReportComponentAction = new ClearAllAction(ePane);
@ -68,23 +68,6 @@ public class DeprecatedActionManager {
return clearMenu;
}
/**
* Order menu
*/
public static JMenu getOrderMenu(ElementCasePane ePane) {
JMenu orderMenu = new JMenu(Inter.getLocText("M_Edit-Order"));
orderMenu.setIcon(UIConstants.BLACK_ICON);
orderMenu.setMnemonic('O');
orderMenu.setBackground(UIConstants.NORMAL_BACKGROUND);
orderMenu.add(new BringFloatElementToFrontAction(ePane).createMenuItem());
orderMenu.add(new SendFloatElementToBackAction(ePane).createMenuItem());
orderMenu.add(new BringFloatElementForwardAction(ePane).createMenuItem());
orderMenu.add(new SendFloatElementBackwardAction(ePane).createMenuItem());
return orderMenu;
}
/**
* Cell Style.
*/

4
designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java

@ -75,9 +75,7 @@ public class ElementCasePaneDelegate extends ElementCasePane<WorkSheet> {
EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance());
return;
}
if (DesignerContext.getDesignerFrame().getSelectedJTemplate() != null) {
CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this);
}
CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this);
CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this);
QuickEditorRegion.getInstance().populate(getCurrentEditor());
JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();

7
designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -70,9 +70,10 @@ public class AlphaFineConstants {
public static final String PLUGIN_SEARCH_URL = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI");
public static final String PLUGIN_URL = SiteCenter.getInstance().acquireUrlByKind("af.plugin");
public static final String PLUGIN_URL = SiteCenter.getInstance().acquireUrlByKind("af.pluginInfo");
public static final String REUSE_URL = SiteCenter.getInstance().acquireUrlByKind("af.reuseInfo");
public static final String REUSE_URL = SiteCenter.getInstance().acquireUrlByKind("af.reuse");
public static final String DOCUMENT_DOC_URL = SiteCenter.getInstance().acquireUrlByKind("af.doc_view");
@ -87,4 +88,6 @@ public class AlphaFineConstants {
public static final String SEARCH_API = SiteCenter.getInstance().acquireUrlByKind("af.cloud_search");
}

8
designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -7,8 +7,8 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.NoResultModel;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.general.Inter;
import com.fr.general.ProcessCanceledException;
import com.fr.stable.StringUtils;
@ -89,8 +89,8 @@ public class AlphaFineHelper {
}
public static List<AlphaCellModel> getFilterResult() {
List<AlphaCellModel> recentList = RecentSearchManager.getRecentSearchManger().getRecentModelList();
List<AlphaCellModel> recommendList = RecommendSearchManager.getRecommendSearchManager().getRecommendModelList();
List<AlphaCellModel> recentList = RecentSearchManager.getInstance().getRecentModelList();
List<AlphaCellModel> recommendList = RecommendSearchManager.getInstance().getRecommendModelList();
SearchResult filterResult = new SearchResult();
filterResult.addAll(recentList);
filterResult.addAll(recommendList);

8
designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java

@ -2,10 +2,10 @@ package com.fr.design.mainframe.alphafine.cell;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.search.manager.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import com.fr.json.JSONObject;
/**

77
designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -1,53 +1,48 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.base.FRContext;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.env.RemoteEnv;
import com.fr.general.FRLogger;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.fr.stable.StringUtils;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class PluginModel extends AlphaCellModel {
private static final String PLUGIN_INFORMATION_URL = "http://shop.finereport.com/ShopServer?pg=plugin&pid=";
private static final String REUSE_INFORMATION_URL = "http://shop.finereport.com/reuses/";
private String pluginUrl;
private String imageUrl;
private String version;
private String jartime;
private String link;
private String informationUrl;
private int pluginId;
private String pluginId;
private int id;
private int price;
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId, int serchCount) {
this(name, content, imageUrl, version, jartime, link, type, price, pluginId);
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, String pluginId, CellType type, int price, int id, int serchCount) {
this(name, content, imageUrl, version, jartime, link, pluginId, type, price, id);
setSearchCount(serchCount);
}
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId) {
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, String pluginId, CellType type, int price, int id) {
super(name, content);
this.link = link;
setType(type);
this.pluginId = pluginId;
if (getType() == CellType.PLUGIN) {
this.pluginUrl = AlphaFineConstants.PLUGIN_URL + pluginId;
this.informationUrl = PLUGIN_INFORMATION_URL + this.pluginId;
} else {
this.pluginUrl = AlphaFineConstants.REUSE_URL + pluginId;
this.informationUrl = REUSE_INFORMATION_URL + this.pluginId;
}
this.id = id;
this.imageUrl = imageUrl;
this.jartime = jartime;
this.version = version;
this.price = price;
this.pluginId = pluginId;
if (getType() == CellType.PLUGIN) {
this.informationUrl = AlphaFineConstants.PLUGIN_URL + id;
} else {
this.informationUrl = AlphaFineConstants.REUSE_URL + id;
}
}
public String getImageUrl() {
@ -58,14 +53,6 @@ public class PluginModel extends AlphaCellModel {
this.imageUrl = imageUrl;
}
public String getPluginUrl() {
return pluginUrl;
}
public void setPluginUrl(String pluginUrl) {
this.pluginUrl = pluginUrl;
}
public String getVersion() {
return version;
}
@ -103,7 +90,7 @@ public class PluginModel extends AlphaCellModel {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getTypeValue()).put("price", getPrice()).put("id", getPluginId()).put("link", getLink()).put("searchCount", getSearchCount());
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("id", getId()).put("pluginid", getPluginId()).put("type", getType().getTypeValue()).put("price", getPrice()).put("link", getLink()).put("searchCount", getSearchCount());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
@ -119,16 +106,12 @@ public class PluginModel extends AlphaCellModel {
@Override
public void doAction() {
try {
Desktop.getDesktop().browse(new URI(getPluginUrl()));
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {
FRLogger.getLogger().error(e.getMessage());
if (StringUtils.isBlank(this.pluginId) || FRContext.getCurrentEnv() instanceof RemoteEnv) {
return;
}
WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]");
}
@Override
public boolean equals(Object o) {
if (this == o) {
@ -139,21 +122,21 @@ public class PluginModel extends AlphaCellModel {
}
PluginModel that = (PluginModel) o;
return pluginUrl != null ? pluginUrl.equals(that.pluginUrl) : that.pluginUrl == null;
return pluginId != null ? pluginId.equals(that.pluginId) : that.pluginId == null;
}
@Override
public int hashCode() {
return pluginUrl != null ? pluginUrl.hashCode() : 0;
return pluginId != null ? pluginId.hashCode() : 0;
}
public int getPluginId() {
return pluginId;
public int getId() {
return id;
}
public void setPluginId(int pluginId) {
this.pluginId = pluginId;
public void setId(int id) {
this.id = id;
}
public String getInformationUrl() {
@ -163,4 +146,12 @@ public class PluginModel extends AlphaCellModel {
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
}
public String getPluginId() {
return pluginId;
}
public void setPluginId(String pluginId) {
this.pluginId = pluginId;
}
}

58
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -23,12 +23,12 @@ import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.preview.FilePreviewPane;
import com.fr.design.mainframe.alphafine.preview.NoResultPane;
import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.search.manager.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
@ -445,47 +445,35 @@ public class AlphaFineDialog extends UIDialog {
}
private void buildDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : documentModelList) {
searchListModel.addElement(object);
}
addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildFileList(final String searchText) {
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : fileModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
addSearchResult(FileSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildActionList(final String searchText) {
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : actionModelList) {
searchListModel.addElement(object);
}
addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildPluginList(final String searchText) {
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : pluginModelList) {
searchListModel.addElement(object);
}
addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildRecommendList(final String searchText) {
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : recommendModelList) {
searchListModel.addElement(object);
}
addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildRecentList(final String searchText) {
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText);
for (AlphaCellModel object : recentModelList) {
addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(searchText));
}
private synchronized void addSearchResult(SearchResult searchResult) {
for (AlphaCellModel object : searchResult) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
/**
@ -758,7 +746,7 @@ public class AlphaFineDialog extends UIDialog {
* @param cellModel
*/
private void saveLocalHistory(AlphaCellModel cellModel) {
RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger();
RecentSearchManager recentSearchManager = RecentSearchManager.getInstance();
recentSearchManager.addRecentModel(storeText, cellModel);
recentSearchManager.saveXMLFile();
sendDataToServer(storeText, cellModel);
@ -824,16 +812,16 @@ public class AlphaFineDialog extends UIDialog {
SearchResult moreResult;
switch (selectedValue.getContentType()) {
case PLUGIN:
moreResult = PluginSearchManager.getPluginSearchManager().getMoreSearchResult();
moreResult = PluginSearchManager.getInstance().getMoreSearchResult(searchTextField.getText());
break;
case DOCUMENT:
moreResult = DocumentSearchManager.getDocumentSearchManager().getMoreSearchResult();
moreResult = DocumentSearchManager.getInstance().getMoreSearchResult(searchTextField.getText());
break;
case FILE:
moreResult = FileSearchManager.getFileSearchManager().getMoreSearchResult();
moreResult = FileSearchManager.getInstance().getMoreSearchResult(searchTextField.getText());
break;
case ACTION:
moreResult = ActionSearchManager.getActionSearchManager().getMoreSearchResult();
moreResult = ActionSearchManager.getInstance().getMoreSearchResult(searchTextField.getText());
break;
default:
moreResult = new SearchResult();

6
designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java

@ -1,11 +1,11 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.fun;
import com.fr.design.mainframe.alphafine.model.SearchResult;
/**
* Created by XiaXiang on 2017/3/27.
*/
public interface AlphaFineSearchProcessor {
public interface AlphaFineSearchProvider {
/**
* 获取默认显示条数
*
@ -19,5 +19,5 @@ public interface AlphaFineSearchProcessor {
*
* @return
*/
SearchResult getMoreSearchResult();
SearchResult getMoreSearchResult(String searchText);
}

10
designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
@ -8,6 +8,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.design.mainframe.toolbar.UpdateActionModel;
import com.fr.general.ComparatorUtils;
@ -20,13 +21,13 @@ import java.util.List;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class ActionSearchManager implements AlphaFineSearchProcessor {
public class ActionSearchManager implements AlphaFineSearchProvider {
private static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static ActionSearchManager getActionSearchManager() {
public synchronized static ActionSearchManager getInstance() {
if (actionSearchManager == null) {
actionSearchManager = new ActionSearchManager();
}
@ -63,6 +64,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) {
List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateActionModel updateActionModel : updateActions) {
AlphaFineHelper.checkCancel();
if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) {
if (updateActionModel.getSearchKey().contains(searchText) && updateActionModel.getAction().isEnabled()) {
filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()));
@ -91,7 +93,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult getMoreSearchResult() {
public SearchResult getMoreSearchResult(String searchText) {
return moreModelList;
}
}

9
designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
@ -7,6 +7,7 @@ import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.DocumentModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
@ -18,12 +19,12 @@ import com.fr.stable.StringUtils;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class DocumentSearchManager implements AlphaFineSearchProcessor {
public class DocumentSearchManager implements AlphaFineSearchProvider {
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static DocumentSearchManager getDocumentSearchManager() {
public synchronized static DocumentSearchManager getInstance() {
if (documentSearchManager == null) {
documentSearchManager = new DocumentSearchManager();
@ -106,7 +107,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult getMoreSearchResult() {
public SearchResult getMoreSearchResult(String searchText) {
return moreModelList;
}

104
designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.Env;
import com.fr.base.FRContext;
@ -6,10 +6,10 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.FileModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
@ -31,7 +31,7 @@ import java.util.List;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class FileSearchManager implements AlphaFineSearchProcessor {
public class FileSearchManager implements AlphaFineSearchProvider {
private static final int MARK_LENGTH = 6;
private static final String DS_NAME = "dsname=\"";
private static final String FRM_PREFIX = "k:frm ";
@ -39,13 +39,14 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
private static FileSearchManager fileSearchManager = null;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
private List<FileNode> fileNodes = null;
//停止搜索
private boolean stopSearch = false;
//隐藏的搜索功能,可根据特殊的字符标记判断搜索分类
private boolean isContainCpt = true;
private boolean isContainFrm = true;
public synchronized static FileSearchManager getFileSearchManager() {
public synchronized static FileSearchManager getInstance() {
init();
return fileSearchManager;
}
@ -72,52 +73,66 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
public synchronized SearchResult getLessSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (searchText.startsWith(FRM_PREFIX)) {
isContainCpt = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length());
} else if (searchText.startsWith(CPT_PREFIX)) {
isContainFrm = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length());
}
searchText = dealWithSearchText(searchText);
if (StringUtils.isBlank(searchText) || ComparatorUtils.equals(searchText, DS_NAME)) {
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_Templates")));
return lessModelList;
}
Env env = FRContext.getCurrentEnv();
fileNodes = new ArrayList<>();
fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true);
AlphaFineHelper.checkCancel();
isContainCpt = true;
isContainFrm = true;
doSearch(searchText, true, env);
if (stopSearch) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE));
lessModelList.addAll(filterModelList.subList(0, AlphaFineConstants.SHOW_SIZE));
stopSearch = false;
return this.lessModelList;
}
if (filterModelList.isEmpty()) {
return new SearchResult();
}
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), false, CellType.FILE));
lessModelList.addAll(filterModelList);
return lessModelList;
}
@Override
public SearchResult getMoreSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
searchText = dealWithSearchText(searchText);
Env env = FRContext.getCurrentEnv();
AlphaFineHelper.checkCancel();
isContainCpt = true;
isContainFrm = true;
doSearch(searchText, false, env);
lessModelList.addAll(filterModelList.subList(AlphaFineConstants.SHOW_SIZE, filterModelList.size()));
return lessModelList;
}
private void doSearch(String searchText, boolean needMore, Env env) {
for (FileNode node : fileNodes) {
boolean isAlreadyContain = false;
String fileEnvPath = node.getEnvPath();
String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath);
isAlreadyContain = searchFile(searchText, node, isAlreadyContain);
searchFileContent(searchText, node, isAlreadyContain, filePath);
isAlreadyContain = searchFile(searchText, node, isAlreadyContain, needMore);
searchFileContent(searchText, node, isAlreadyContain, filePath, needMore);
}
SearchResult result = new SearchResult();
for (AlphaCellModel object : filterModelList) {
if (!AlphaFineHelper.getFilterResult().contains(object)) {
result.add(object);
}
}
private String dealWithSearchText(String searchText) {
if (searchText.startsWith(FRM_PREFIX)) {
isContainCpt = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length());
} else if (searchText.startsWith(CPT_PREFIX)) {
isContainFrm = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length());
}
if (result.isEmpty()) {
return lessModelList;
} else if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates")));
lessModelList.addAll(result);
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE));
lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size()));
}
return this.lessModelList;
return searchText;
}
/**
@ -128,7 +143,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
* @param isAlreadyContain
* @param filePath
*/
private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, String filePath) {
private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, String filePath, boolean needMore) {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent()) {
try {
@ -146,7 +161,12 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
if (isFoundInContent && !isAlreadyContain) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model);
if (!AlphaFineHelper.getFilterResult().contains(model)) {
filterModelList.add(model);
}
if (this.filterModelList.size() > AlphaFineConstants.SHOW_SIZE && needMore) {
stopSearch = true;
}
}
isr.close();
reader.close();
@ -166,22 +186,22 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
* @param isAlreadyContain
* @return
*/
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) {
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText)) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model);
if (!AlphaFineHelper.getFilterResult().contains(model)) {
filterModelList.add(model);
}
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE && needMore) {
stopSearch = true;
}
isAlreadyContain = true;
}
}
return isAlreadyContain;
}
@Override
public SearchResult getMoreSearchResult() {
return moreModelList;
}
/**
* 获取工作目录下所有符合要求的模板
*

16
designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
@ -7,6 +7,7 @@ import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.PluginModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
@ -22,13 +23,13 @@ import java.net.URLEncoder;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProcessor {
public class PluginSearchManager implements AlphaFineSearchProvider {
private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static PluginSearchManager getPluginSearchManager() {
public synchronized static PluginSearchManager getInstance() {
if (pluginSearchManager == null) {
pluginSearchManager = new PluginSearchManager();
}
@ -39,13 +40,14 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) {
String name = object.optString("name");
String content = object.optString("description");
int pluginId = object.optInt("id");
String pluginId = object.optString("pluginid");
int id = object.optInt("id");
int searchCount = object.optInt("searchCount");
String imageUrl = null;
try {
imageUrl = isFromCloud ? AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8") : object.optString("pic");
} catch (UnsupportedEncodingException e) {
FRLogger.getLogger().error(e.getMessage());
FRLogger.getLogger().error("plugin icon error: " + e.getMessage());
}
String version = null;
String jartime = null;
@ -59,7 +61,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
type = CellType.REUSE;
}
int price = object.optInt("price");
return new PluginModel(name, content, imageUrl, version, jartime, link, type, price, pluginId, searchCount);
return new PluginModel(name, content, imageUrl, version, jartime, link, pluginId, type, price, id, searchCount);
}
/**
@ -137,7 +139,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult getMoreSearchResult() {
public SearchResult getMoreSearchResult(String searchText) {
return this.moreModelList;
}
}

32
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java

@ -1,7 +1,8 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
@ -10,6 +11,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils;
@ -42,9 +44,9 @@ import java.util.Map;
/**
* Created by XiaXiang on 2017/5/15.
*/
public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProcessor {
public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProvider {
private static final String XML_TAG = "AlphaFineRecent";
private static final String XML_TAG = "AFSearch_Recent";
private static final int MAX_SIZE = 3;
private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null;
@ -52,7 +54,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private SearchResult recentModelList;
private Map<String, SearchResult> recentKVModelMap = new HashMap<>();
public synchronized static RecentSearchManager getRecentSearchManger() {
public synchronized static RecentSearchManager getInstance() {
if (recentSearchManager == null) {
recentSearchManager = new RecentSearchManager();
try {
@ -140,7 +142,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
@Override
public String fileName() {
return "AlphaFine_Recent.xml";
return "AFSearch_Recent.xml";
}
@ -156,8 +158,16 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return recentFile;
}
private File getOldFile() {
return new File(ProductConstants.getEnvHome() + File.separator + "AlphaFine_Recent.xml");
}
private File getRecentEnvFile() {
File envFile = getRecentFile();
File oldFile = getOldFile();
if (oldFile.exists()) {
StableUtils.deleteFile(oldFile);
}
if (!envFile.exists()) {
createRecentFile(envFile);
}
@ -172,7 +182,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private void createRecentFile(File envFile) {
try {
FileWriter fileWriter = new FileWriter(envFile);
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><AlphaFineRecent></AlphaFineRecent>");
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><AFSearch_Recent></AFSearch_Recent>");
Utils.copyCharTo(stringReader, fileWriter);
stringReader.close();
fileWriter.close();
@ -233,8 +243,12 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
SearchResult searchResult = new SearchResult();
while (modelIterator.hasNext()) {
AlphaCellModel model = modelIterator.next();
if (model.getType() == CellType.ACTION && !UpdateActionManager.getUpdateActionManager().isEnable(((ActionModel) model).getAction())) {
continue;
if (model.getType() == CellType.ACTION) {
UpdateAction action = UpdateActionManager.getUpdateActionManager().getActionByName(model.getName());
if (action != null) {
((ActionModel) model).setAction(action);
searchResult.add(model);
}
} else {
searchResult.add(model);
}
@ -296,7 +310,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
}
@Override
public SearchResult getMoreSearchResult() {
public SearchResult getMoreSearchResult(String searchText) {
return new SearchResult();
}

18
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.alphafine.search.manager;
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
@ -10,6 +9,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
@ -25,12 +25,12 @@ import java.util.List;
/**
* Created by XiaXiang on 2017/3/31.
*/
public class RecommendSearchManager implements AlphaFineSearchProcessor {
public class RecommendSearchManager implements AlphaFineSearchProvider {
private static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList;
private SearchResult recommendModelList;
public synchronized static RecommendSearchManager getRecommendSearchManager() {
public synchronized static RecommendSearchManager getInstance() {
if (recommendSearchManager == null) {
recommendSearchManager = new RecommendSearchManager();
}
@ -44,14 +44,12 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
this.recommendModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) {
String result;
String url = AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText);
url = String.format("%s?token=%s", url, SiteCenterToken.generateToken());
HttpClient httpClient = new HttpClient(url);
HttpClient httpClient = new HttpClient(AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText));
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return getNoConnectList();
}
httpClient.setTimeout(5000);
httpClient.setTimeout(3000);
result = httpClient.getResponseText();
AlphaFineHelper.checkCancel();
try {
@ -93,7 +91,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
* @return
*/
private boolean alreadyContain(AlphaCellModel cellModel) {
return RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(cellModel) || this.recommendModelList.contains(cellModel);
return RecentSearchManager.getInstance().getRecentModelList().contains(cellModel) || this.recommendModelList.contains(cellModel);
}
private SearchResult getNoConnectList() {
@ -104,7 +102,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult getMoreSearchResult() {
public SearchResult getMoreSearchResult(String searchText) {
return new SearchResult();
}

2
designer/src/com/fr/design/widget/WidgetEventPane.java

@ -91,7 +91,7 @@ public class WidgetEventPane extends ObjectUIControlPane {
@Override
protected DBManipulationPane createDBManipulationPane() {
if(epane == null) {
if(epane == null && DesignerContext.getDesignerFrame().getSelectedJTemplate() != null) {
return autoCreateDBManipulationInWidgetEventPane();
}

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

@ -1,32 +1,35 @@
package com.fr.grid.selection;
import java.awt.Toolkit;
import javax.swing.JPopupMenu;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.cell.CleanAuthorityAction;
import com.fr.design.actions.cell.FloatStyleAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.*;
import com.fr.design.actions.utils.DeprecatedActionManager;
import com.fr.design.actions.edit.order.BringFloatElementForwardAction;
import com.fr.design.actions.edit.order.BringFloatElementToFrontAction;
import com.fr.design.actions.edit.order.SendFloatElementBackwardAction;
import com.fr.design.actions.edit.order.SendFloatElementToBackAction;
import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.ElementCasePane.Clear;
import com.fr.design.selection.QuickEditor;
import com.fr.design.utils.DesignUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.design.selection.QuickEditor;
import com.fr.stable.ColumnRow;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.OLDPIX;
import com.fr.design.utils.DesignUtils;
import javax.swing.*;
import java.awt.*;
/**
* the float selection
* @editor zhou
@ -114,24 +117,28 @@ public class FloatSelection extends Selection {
@Override
public JPopupMenu createPopupMenu(ElementCasePane ePane) {
JPopupMenu popup = new JPopupMenu();
UIPopupMenu popup = new UIPopupMenu();
if (BaseUtils.isAuthorityEditing()) {
popup.add(new CleanAuthorityAction(ePane).createMenuItem());
return popup;
}
popup.add(DeprecatedActionManager.getCellMenu(ePane).createJMenu());
popup.add(new FloatStyleAction(ePane).createMenuItem());
popup.add(new HyperlinkAction().createMenuItem());
// cut, copy and paste
popup.addSeparator();
popup.add(new CutAction(ePane).createMenuItem());
popup.add(new CopyAction(ePane).createMenuItem());
popup.add(new PasteAction(ePane).createMenuItem());
popup.add(new DeleteAction(ePane).createMenuItem());
popup.addSeparator();
popup.add(new BringFloatElementToFrontAction(ePane).createMenuItem());
popup.add(new SendFloatElementToBackAction(ePane).createMenuItem());
popup.add(new BringFloatElementForwardAction(ePane).createMenuItem());
popup.add(new SendFloatElementBackwardAction(ePane).createMenuItem());
popup.addSeparator();
popup.add(DeprecatedActionManager.getOrderMenu(ePane));
popup.add(new EditFloatElementNameAction(ePane).createMenuItem());
return popup;

24
designer_base/src/com/fr/design/DesignerEnvManager.java

@ -61,6 +61,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private static final int MAX_SHOW_NUM = 10;
private static final String VERSION_80 = "80";
private static final int CACHINGTEMPLATE_LIMIT = 5;
private static DesignerEnvManager designerEnvManager; // gui.
private String activationKey = null;
@ -99,6 +100,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int language;
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;
private boolean autoBackUp = true;
private int undoLimit = 5;
private short pageLengthUnit = Constants.UNIT_MM;
@ -244,7 +246,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
// 写文件的LogLocation
String logLocation = DesignerEnvManager.getEnvManager().getLogLocation();
if (logLocation != null) {
//Mac下8.0,9.0 选项-日志设置为空时在根目录下检测文件存在会抛无权限,这里应该设个默认值比较好吧
if (StringUtils.isNotEmpty(logLocation)) {
try {
Calendar calender = GregorianCalendar.getInstance();
calender.setTimeInMillis(System.currentTimeMillis());
@ -631,6 +634,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.useOracleSystemSpace = displayOracleSystem;
}
/**
* 配置最大缓存模板个数
*/
public void setCachingTemplateLimit(int cachingTemplateLimit) {
this.cachingTemplateLimit = cachingTemplateLimit;
}
/**
* 获取最大缓存模板个数
*/
public int getCachingTemplateLimit() {
return this.cachingTemplateLimit;
}
/**
* 是否加入产品改良
*
@ -1394,6 +1412,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setMaxNumberOrPreviewRow(reader.getAttrAsInt("maxNumberOrPreviewRow", 200));
this.setOracleSystemSpace(reader.getAttrAsBoolean("useOracleSystemSpace", true));
this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT));
this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true));
this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true));
this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false));
@ -1614,6 +1633,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (!this.isOracleSystemSpace()) {
writer.attr("useOracleSystemSpace", this.isOracleSystemSpace());
}
if (this.getCachingTemplateLimit() >= 0) {
writer.attr("cachingTemplateLimit", this.getCachingTemplateLimit());
}
if (!this.isJoinProductImprove()) {
writer.attr("joinProductImprove", this.isJoinProductImprove());
}

23
designer_base/src/com/fr/design/actions/file/PreferencePane.java

@ -16,6 +16,7 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
@ -32,6 +33,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
@ -64,6 +66,9 @@ public class PreferencePane extends BasicPane {
private static final int MAX_UNDO_LIMIT_50 = 50;
private static final int SELECTED_INDEX_4 = 4;
private static final int SELECTED_INDEX_5 = 5;
private static final int CACHING_MAX = 10;
private static final int CACHING_DEFAULT = 5;
private static final int CACHING_GAP = 5;
private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+";
@ -122,6 +127,7 @@ public class PreferencePane extends BasicPane {
private IntegerEditor portEditor;
private UITextField jdkHomeTextField;
private UICheckBox oracleSpace;
private UISpinner cachingTemplateSpinner;
private UICheckBox joinProductImprove;
public PreferencePane() {
@ -182,6 +188,7 @@ public class PreferencePane extends BasicPane {
JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
spaceUpPane.add(oraclePane, BorderLayout.NORTH);
spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER);
spaceUpPane.add(improvePane, BorderLayout.SOUTH);
advancePane.add(spaceUpPane);
}
@ -505,6 +512,20 @@ public class PreferencePane extends BasicPane {
serverPortPane.add(choosePortPane, BorderLayout.CENTER);
}
private JPanel createMemoryPane() {
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Preference_CachingTemplate"));
UILabel memoryLabel = new UILabel(Inter.getLocText("FR-Designer_Preference_MaxCachingTemplate"));
UILabel memoryTipLabel = new UILabel(Inter.getLocText("FR-Designer_Preference_CachingTemplateTip"));
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder( 0, CACHING_GAP, 0, 0));
cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
memorySpace.add(memoryLabel);
memorySpace.add(cachingTemplateSpinner);
memorySpace.add(memoryTipLabel);
memoryPane.add(memorySpace);
return memoryPane;
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("M_Window-Preference");
@ -563,6 +584,7 @@ public class PreferencePane extends BasicPane {
this.jdkHomeTextField.setText(designerEnvManager.getJdkHome());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove());
}
@ -623,6 +645,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setJdkHome(jdkHomeTextField.getText());
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());
// designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected());

2
designer_base/src/com/fr/design/constants/UIConstants.java

@ -79,6 +79,8 @@ public interface UIConstants {
public static final Color COMBOBOX_BTN_NORMAL = new Color(0xD9DADD);
public static final Color COMBOBOX_BTN_ROLLOVER = new Color(0xC8C9CD);
public static final Color COMBOBOX_BTN_PRESS = new Color(0xD8F2FD);
public static final Color UIPOPUPMENU_LINE_COLOR = new Color(0xC8C9CD);
public static final Color UIPOPUPMENU_BACKGROUND = new Color(0xEDEDEE);
public static final Color LINE_COLOR = new Color(153, 153, 153);
public static final Color FONT_COLOR = new Color(51, 51, 51);
public static final Color LIGHT_BLUE = new Color(182, 217, 253);

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

@ -20,7 +20,7 @@ import netscape.javascript.JSObject;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Desktop;
import java.awt.*;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
@ -57,6 +57,7 @@ public class LoginWebBridge {
private static final int TIME_OUT = 10000;
private static final String LOGIN_SUCCESS = "ok";
private static final String LOGIN_FAILED = "failed";
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static LoginWebBridge helper;
private UIDialog uiDialog;
@ -250,6 +251,7 @@ public class LoginWebBridge {
private void loginSuccess(String username) {
closeWindow();
uiLabel.setText(username);
uiLabel.setBackground(LOGIN_BACKGROUND);
}
/**

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

@ -54,6 +54,7 @@ public class PluginWebBridge {
private static final String THREAD_NAME_TEMPLATE = "pluginbridge-thread-%s";
private static final String ACTION = "action";
private static final String KEYWORD = "keyword";
private static final String PLUGIN_INFO = "pluginInfo";
private static final int COREPOOLSIZE = 3;
private static final int MAXPOOLSIZE = 5;
@ -72,20 +73,7 @@ public class PluginWebBridge {
new LinkedBlockingQueue<Runnable>(COREPOOLSIZE),
new ThreadFactoryBuilder().setNameFormat(THREAD_NAME_TEMPLATE).build());
/**
* 动作枚举
*/
public enum ACTIONS {
SEARCH("search");
private String context;
ACTIONS(String context) {
this.context = context;
}
public String getContext() {
return context;
}
private PluginWebBridge() {
}
public static PluginWebBridge getHelper() {
@ -106,9 +94,6 @@ public class PluginWebBridge {
return helper;
}
private PluginWebBridge() {
}
/**
* 获取打开动作配置
*
@ -155,12 +140,26 @@ public class PluginWebBridge {
*
* @param keyword 关键词
*/
public void openWithSearch(String keyword) {
HashMap<String, Object> map = new HashMap<String, Object>(2);
map.put(KEYWORD, keyword);
setRunConfig(ACTIONS.SEARCH, map);
}
/**
* 根据插件信息跳转到应用中心
*
* @param keyword
* @param pluginInfo
*/
public void showResultInStore(String keyword, String pluginInfo) {
HashMap<String, Object> map = new HashMap<>();
map.put(KEYWORD, keyword);
map.put(PLUGIN_INFO, pluginInfo);
setRunConfig(ACTIONS.SHOW_RESULT, map);
}
public void setEngine(WebEngine webEngine) {
this.webEngine = webEngine;
}
@ -182,7 +181,6 @@ public class PluginWebBridge {
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback);
}
/**
* 从磁盘上选择插件安装包进行安装
*
@ -204,7 +202,6 @@ public class PluginWebBridge {
PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback);
}
/**
* 从插件服务器上更新选中的插件
*
@ -346,13 +343,11 @@ public class PluginWebBridge {
threadPoolExecutor.submit(task);
}
public void getPluginPrefix(final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginPrefixExecutor());
threadPoolExecutor.submit(task);
}
/**
* 在线获取插件分类
*
@ -487,9 +482,6 @@ public class PluginWebBridge {
}
}
/*-------------------------------登录部分的处理----------------------------------*/
/**
* 注册页面
*/
@ -501,6 +493,9 @@ public class PluginWebBridge {
}
}
/*-------------------------------登录部分的处理----------------------------------*/
/**
* 忘记密码
*/
@ -577,4 +572,20 @@ public class PluginWebBridge {
return true;
}
/**
* 动作枚举
*/
public enum ACTIONS {
SEARCH("search"), SHOW_RESULT("showResult");
private String context;
ACTIONS(String context) {
this.context = context;
}
public String getContext() {
return context;
}
}
}

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

@ -129,6 +129,16 @@ public class WebViewDlgHelper {
createPluginDialog();
}
/**
* 以关键词打开设计器商店显示搜索结果
* @param keyword
* @param data
*/
public static void showPluginInStore(String keyword, String data) {
PluginWebBridge.getHelper().showResultInStore(keyword, data);
createPluginDialog();
}
public static void createLoginDialog() {
if (StableUtils.getMajorJavaVersion() == VERSION_8) {
File file = new File(StableUtils.pathJoin(installHome, "scripts"));

2
designer_base/src/com/fr/design/file/HistoryTemplateListPane.java

@ -38,7 +38,7 @@ import com.fr.design.utils.gui.GUIPaintUtils;
public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存
private static final int DEAD_LINE = 5;
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();
private static final int LIST_BORDER = 4;
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;

5
designer_base/src/com/fr/design/file/MutilTempalteTabPane.java

@ -8,7 +8,6 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIScrollPopUpMenu;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.file.FILE;
@ -17,6 +16,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants;
import com.fr.stable.project.ProjectConstants;
@ -701,8 +701,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
if (filename.startsWith(ProjectConstants.REPORTLETS_NAME)) {
filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename;
}
filename = filename.replaceAll("/", "\\\\");
filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/");
if (!specifiedTemplate.isALLSaved()) {
specifiedTemplate.stopEditing();

6
designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java

@ -219,10 +219,10 @@ public abstract class UIListControlPane extends UIControlPane {
return;
}
for (Nameable aNameableArray : nameableArray) {
listModel.addElement(new ListModelElement(aNameableArray));
listModel.setSize(nameableArray.length);
for (int i = 0; i < nameableArray.length; i++) {
listModel.set(i, new ListModelElement(nameableArray[i]));
}
if (listModel.size() > 0 || this.nameableList.getSelectedIndex() != 0) {
this.nameableList.setSelectedIndex(0);
}

274
designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java

@ -0,0 +1,274 @@
package com.fr.design.gui.imenu;
import com.fr.design.constants.UIConstants;
import com.fr.design.utils.gui.GUIPaintUtils;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
public class UIHeadMenu extends UIMenu {
private static final float REC = 8f;
private JPopupMenu popupMenu;
public UIHeadMenu(String name) {
super(name);
}
public JPopupMenu getPopupMenu() {
ensurePopupMenuCreated();
popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND);
popupMenu.setBorder(new Border() {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
GUIPaintUtils.paintShapeBorder(g2d, x, y, width, height, rec);
if (!(UIHeadMenu.this.getParent() instanceof JPopupMenu)) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.drawLine(1, 0, UIHeadMenu.this.getWidth() - 2, 0);
}
}
@Override
public boolean isBorderOpaque() {
return false;
}
@Override
public Insets getBorderInsets(Component c) {
return new Insets(5, 2, 10, 10);
}
});
return popupMenu;
}
protected void ensurePopupMenuCreated() {
if (popupMenu == null) {
this.popupMenu = new JPopupMenu() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
float wdith = getWidth();
float heigth = getHeight();
Shape shape = GUIPaintUtils.paintShape(g2d, wdith, heigth, REC);
g2d.setClip(shape);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2d);
}
};
popupMenu.setInvoker(this);
popupListener = createWinListener(popupMenu);
}
}
/**
*画界面
*/
@Override
public void updateUI() {
setUI(new UIMenuUI());
}
/**
* 判断popupmeu是否隐藏
* @return 如果隐藏 返回true
*/
public boolean isPopupMenuVisible() {
ensurePopupMenuCreated();
return popupMenu.isVisible();
}
/**
* 设置popupmenu位置
* @param x
* @param y
*/
public void setMenuLocation(int x, int y) {
super.setMenuLocation(x, y);
if (popupMenu != null) {
popupMenu.setLocation(x, y);
}
}
/**
* 向popupmenu添加 JMenuItem
* @param menuItem 菜单项
* @return 菜单项
*/
public JMenuItem add(JMenuItem menuItem) {
ensurePopupMenuCreated();
return popupMenu.add(menuItem);
}
/**
* 添加组件
* @param c 组件
* @return 组件
*/
public Component add(Component c) {
ensurePopupMenuCreated();
popupMenu.add(c);
return c;
}
/**
* 向指定位置添加组件
* @param c 组件
* @param index 位置
* @return 组件
*/
public Component add(Component c, int index) {
ensurePopupMenuCreated();
popupMenu.add(c, index);
return c;
}
/**
* 添加分隔符
*/
public void addSeparator() {
ensurePopupMenuCreated();
popupMenu.addSeparator();
}
/**
* 添加menuitem到指定位置
* @param s 字符
* @param pos 位置
*/
public void insert(String s, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JMenuItem(s), pos);
}
/**
* 添加么会特么到指定位置
* @param mi 菜单项
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(JMenuItem mi, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加到指定位置
* @param a 事件
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(Action a, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
JMenuItem mi = new JMenuItem(a);
mi.setHorizontalTextPosition(JButton.TRAILING);
mi.setVerticalTextPosition(JButton.CENTER);
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加分隔符到指定位置
* @param index 指定位置
*/
public void insertSeparator(int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JPopupMenu.Separator(), index);
}
/**
* 移除
* @param item 菜单项
*/
public void remove(JMenuItem item) {
if (popupMenu != null) {
popupMenu.remove(item);
}
}
/**
* 移除指定位置菜单项
* @param pos 指定位置
*/
public void remove(int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
if (pos > getItemCount()) {
throw new IllegalArgumentException("index greater than the number of items.");
}
if (popupMenu != null) {
popupMenu.remove(pos);
}
}
/**
* 移除组件
* @param c 组件
*/
public void remove(Component c) {
if (popupMenu != null) {
popupMenu.remove(c);
}
}
/**
* 移除所有
*/
public void removeAll() {
if (popupMenu != null) {
popupMenu.removeAll();
}
}
/**
* 组件总数
* @return 组件总数
*/
public int getMenuComponentCount() {
return (popupMenu == null) ? 0 : popupMenu.getComponentCount();
}
/**
* 指定位置组件
* @param n 指定位置
* @return 组件
*/
public Component getMenuComponent(int n) {
return (popupMenu == null) ? null : popupMenu.getComponent(n);
}
/**
* 所有组件
* @return 所有组件
*/
public Component[] getMenuComponents() {
return (popupMenu == null) ? new Component[0] : popupMenu.getComponents();
}
}

237
designer_base/src/com/fr/design/gui/imenu/UIMenu.java

@ -6,8 +6,12 @@ import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
public class UIMenu extends JMenu {
private static final float REC = 8f;
private JPopupMenu popupMenu;
public UIMenu(String name) {
super(name);
setName(name);
@ -24,14 +28,17 @@ public class UIMenu extends JMenu {
}
public JPopupMenu getPopupMenu() {
JPopupMenu popupMenu = super.getPopupMenu();
popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND);
ensurePopupMenuCreated();
popupMenu.setOpaque(false);
popupMenu.setBorder(new Border() {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(UIConstants.LINE_COLOR);
g.drawRect(x, y, width - 1, height - 1);
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g2d.drawRoundRect(x, y, width - 1, height - 1,rec, rec);
if (!(UIMenu.this.getParent() instanceof JPopupMenu)) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.drawLine(1, 0, UIMenu.this.getWidth() - 2, 0);
@ -51,8 +58,230 @@ public class UIMenu extends JMenu {
return popupMenu;
}
protected void ensurePopupMenuCreated() {
if (popupMenu == null) {
this.popupMenu = new JPopupMenu() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(UIConstants.NORMAL_BACKGROUND);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), rec, rec);
g2d.setClip(shape);
super.paintComponent(g2d);
}
};
popupMenu.setInvoker(this);
popupListener = createWinListener(popupMenu);
}
}
/**
*画界面
*/
@Override
public void updateUI() {
setUI(new UIMenuUI());
}
/**
* 判断popupmeu是否隐藏
* @return 如果隐藏 返回true
*/
public boolean isPopupMenuVisible() {
ensurePopupMenuCreated();
return popupMenu.isVisible();
}
/**
* 设置popupmenu位置
* @param x
* @param y
*/
public void setMenuLocation(int x, int y) {
super.setMenuLocation(x, y);
if (popupMenu != null) {
popupMenu.setLocation(x, y);
}
}
/**
* 向popupmenu添加 JMenuItem
* @param menuItem 菜单项
* @return 菜单项
*/
public JMenuItem add(JMenuItem menuItem) {
ensurePopupMenuCreated();
return popupMenu.add(menuItem);
}
/**
* 添加组件
* @param c 组件
* @return 组件
*/
public Component add(Component c) {
ensurePopupMenuCreated();
popupMenu.add(c);
return c;
}
/**
* 向指定位置添加组件
* @param c 组件
* @param index 位置
* @return 组件
*/
public Component add(Component c, int index) {
ensurePopupMenuCreated();
popupMenu.add(c, index);
return c;
}
/**
* 添加分隔符
*/
public void addSeparator() {
ensurePopupMenuCreated();
popupMenu.addSeparator();
}
/**
* 添加menuitem到指定位置
* @param s 字符
* @param pos 位置
*/
public void insert(String s, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JMenuItem(s), pos);
}
/**
* 添加么会特么到指定位置
* @param mi 菜单项
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(JMenuItem mi, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加到指定位置
* @param a 事件
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(Action a, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
JMenuItem mi = new JMenuItem(a);
mi.setHorizontalTextPosition(JButton.TRAILING);
mi.setVerticalTextPosition(JButton.CENTER);
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加分隔符到指定位置
* @param index 指定位置
*/
public void insertSeparator(int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JPopupMenu.Separator(), index);
}
/**
* 移除
* @param item 菜单项
*/
public void remove(JMenuItem item) {
if (popupMenu != null) {
popupMenu.remove(item);
}
}
/**
* 移除指定位置菜单项
* @param pos 指定位置
*/
public void remove(int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
if (pos > getItemCount()) {
throw new IllegalArgumentException("index greater than the number of items.");
}
if (popupMenu != null) {
popupMenu.remove(pos);
}
}
/**
* 移除组件
* @param c 组件
*/
public void remove(Component c) {
if (popupMenu != null) {
popupMenu.remove(c);
}
}
/**
* 移除所有
*/
public void removeAll() {
if (popupMenu != null) {
popupMenu.removeAll();
}
}
/**
* 组件总数
* @return 组件总数
*/
public int getMenuComponentCount() {
return (popupMenu == null) ? 0 : popupMenu.getComponentCount();
}
/**
* 指定位置组件
* @param n 指定位置
* @return 组件
*/
public Component getMenuComponent(int n) {
return (popupMenu == null) ? null : popupMenu.getComponent(n);
}
/**
* 所有组件
* @return 所有组件
*/
public Component[] getMenuComponents() {
return (popupMenu == null) ? new Component[0] : popupMenu.getComponents();
}
}

2
designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java

@ -95,7 +95,7 @@ public class UIMenuItem extends JMenuItem{
} else {
// *** paint the text normally
if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) {
g.setColor(selectionForeground); // Uses protected field.
g.setColor(Color.WHITE); // Uses protected field.
}
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text,
-1, textRect.x, textRect.y + fm.getAscent());

4
designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java

@ -72,8 +72,8 @@ public class UIMenuUI extends BasicMenuUI {
}
} else {
// *** paint the text normally
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
g.setColor(selectionForeground); // Uses protected field.
if (model.isArmed() || (menuItem instanceof JMenu && menuItem.isSelected() && menuItem.getIcon() != null)) {
g.setColor(Color.WHITE); // Uses protected field.
}
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text,
mnemIndex, textRect.x, textRect.y + fm.getAscent());

24
designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java

@ -1,23 +1,37 @@
package com.fr.design.gui.imenu;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import javax.swing.JPopupMenu;
import javax.swing.*;
import com.fr.design.constants.UIConstants;
public class UIPopupMenu extends JPopupMenu{
private static final float REC = 8f;
private boolean onlyText = false;
public UIPopupMenu() {
super();
setBackground(UIConstants.NORMAL_BACKGROUND);
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Shape shape = null;
shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC);
g2d.setClip(shape);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2d);
}
@Override
protected void paintBorder(Graphics g) {
g.setColor(UIConstants.LINE_COLOR);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, rec, rec);
}
@Override

2
designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java

@ -23,7 +23,7 @@ public class UIPopupMenuSeparatorUI extends MetalSeparatorUI {
public void paint(Graphics g, JComponent c) {
Dimension s = c.getSize();
g.setColor(UIConstants.FONT_COLOR);
g.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g.drawLine(2, 1, s.width - 3, 1);
}
}

9
designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java

@ -1,6 +1,7 @@
package com.fr.design.gui.imenu;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import java.awt.*;
@ -16,12 +17,13 @@ import java.awt.event.MouseWheelListener;
*/
public class UIScrollPopUpMenu extends UIPopupMenu {
private static final int MAX_SHOW_NUM = 27;
private static final float REC = 8f;
private UIScrollBar scrollBar;
public UIScrollPopUpMenu() {
super();
setOpaque(false);
setLayout(new ScrollPopupMenuLayout());
super.add(getScrollBar());
addMouseWheelListener(new MouseWheelListener() {
@ -39,6 +41,11 @@ public class UIScrollPopUpMenu extends UIPopupMenu {
public void paintChildren(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(UIConstants.NORMAL_BACKGROUND);
g2d.fillRoundRect(1, 1, getWidth() - 2, getHeight() - 2, rec, rec);
Insets insets = getInsets();
g.clipRect(insets.left, insets.top, getWidth(), getHeight() - insets.top - insets.bottom);
super.paintChildren(g);

BIN
designer_base/src/com/fr/design/images/control/clear.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

BIN
designer_base/src/com/fr/design/images/control/icon_thumb_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

BIN
designer_base/src/com/fr/design/images/control/remove.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

After

Width:  |  Height:  |  Size: 167 B

BIN
designer_base/src/com/fr/design/images/control/to_bottom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

BIN
designer_base/src/com/fr/design/images/control/to_top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

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

@ -2149,3 +2149,18 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect.
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Preference_CachingTemplate=Template memory optimization
FR-Designer_Preference_MaxCachingTemplate=The designer maximum cache template number:
FR-Designer_Preference_CachingTemplateTip=Set to 0 to close the function; restart the designer and take effect
FR-Designer_Move_Up=Move up(F)
FR-Designer_Move_Down=Move down(B)
FR-Designer_Move_To_Top=Move to top(T)
FR-Designer_Move_To_Bottom=Move to bottom(K)
FR-Designer_Tab_Style_Template=Style Template
FR-Designer_Tab_Template_One=Template One
FR-Designer_Tab_Template_Two=Template Two
FR-Designer_Tab_Template_Three=Template Three
FR-Designer_Tab_Template_Four=Template Four
FR-Designer_Tab_Template_Five=Template Five
FR-Designer_Tab_Template_Six=Template Six
FR-Designer_Tab_Display_Position=Display Position

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

@ -2148,3 +2148,18 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect.
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Preference_CachingTemplate=Template memory optimization
FR-Designer_Preference_MaxCachingTemplate=The designer maximum cache template number:
FR-Designer_Preference_CachingTemplateTip=Set to 0 to close the function; restart the designer and take effect
FR-Designer_Move_Up=Move up(F)
FR-Designer_Move_Down=Move down(B)
FR-Designer_Move_To_Top=Move to top(T)
FR-Designer_Move_To_Bottom=Move to bottom(K)
FR-Designer_Tab_Style_Template=Style Template
FR-Designer_Tab_Template_One=Template One
FR-Designer_Tab_Template_Two=Template Two
FR-Designer_Tab_Template_Three=Template Three
FR-Designer_Tab_Template_Four=Template Four
FR-Designer_Tab_Template_Five=Template Five
FR-Designer_Tab_Template_Six=Template Six
FR-Designer_Tab_Display_Position=Display Position

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

@ -2149,3 +2149,18 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570:
FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9
FR-Designer_Env_Des_Https=
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=
FR-Designer_Move_Down=
FR-Designer_Move_To_Top=
FR-Designer_Move_To_Bottom=
FR-Designer_Preference_CachingTemplate=\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u30E1\u30E2\u30EA\u6700\u9069\u5316
FR-Designer_Preference_MaxCachingTemplate=\u8BBE\u8BA1\u5668\u6700\u5927\u30AD\u30E3\u30C3\u30B7\u30E5\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u6570\uFF1A
FR-Designer_Preference_CachingTemplateTip=\u8A2D\u7F6E\u30920\u8868\u793A\u6A5F\u80FD\u8BBE\u8BA1\u5668\u9589\u9396;\u518D\u958B\u5F8C\u767A\u52B9\u3059\u308B
FR-Designer_Tab_Style_Template=
FR-Designer_Tab_Template_One=
FR-Designer_Tab_Template_Two=
FR-Designer_Tab_Template_Three=
FR-Designer_Tab_Template_Four=
FR-Designer_Tab_Template_Five=
FR-Designer_Tab_Template_Six=
FR-Designer_Tab_Display_Position=

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

@ -2149,3 +2149,18 @@ FR-Designer_Export_Background=
FR-Designer_Print_Background=
FR-Designer_Env_Des_Https=
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=
FR-Designer_Move_Down=
FR-Designer_Move_To_Top=
FR-Designer_Move_To_Bottom=
FR-Designer_Preference_CachingTemplate=\uD15C\uD50C\uB9BF \uBA54\uBAA8\uB9AC \uCD5C\uC801\uD654
FR-Designer_Preference_MaxCachingTemplate=\uB514\uC790\uC774\uB108 \uCD5C\uB300 \uCE90\uC2DC \uD15C\uD50C\uB9BF \uAC1C\uC218:
FR-Designer_Preference_CachingTemplateTip=\uC124\uC815 \uC744 0 \uD45C\uC2DC \uB2EB\uAE30 \uC774 \uAE30\uB2A5; \uB2E4\uC2DC \uB514\uC790\uC774\uB108 \uD6C4 \uBC1C\uD6A8\uB41C\uB2E4
FR-Designer_Tab_Style_Template=
FR-Designer_Tab_Template_One=
FR-Designer_Tab_Template_Two=
FR-Designer_Tab_Template_Three=
FR-Designer_Tab_Template_Four=
FR-Designer_Tab_Template_Five=
FR-Designer_Tab_Template_Six=
FR-Designer_Tab_Display_Position=

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

@ -2149,3 +2149,18 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=\u82E5\u542F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8BC1\u4E66\u8DEF\u5F84\u3001https\u79D8\u94A5\uFF09\uFF0C\u5FC5\u987B\u91CD\u542F\u8BBE\u8BA1\u5668\u624D\u80FD\u751F\u6548\u3002
FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801
FR-Designer_Preference_CachingTemplate=\u6A21\u677F\u5185\u5B58\u4F18\u5316
FR-Designer_Preference_MaxCachingTemplate=\u8BBE\u8BA1\u5668\u6700\u5927\u7F13\u5B58\u6A21\u677F\u4E2A\u6570\uFF1A
FR-Designer_Preference_CachingTemplateTip=\u8BBE\u7F6E\u4E3A0\u8868\u793A\u5173\u95ED\u8BE5\u529F\u80FD\uFF1B\u91CD\u542F\u8BBE\u8BA1\u5668\u540E\u751F\u6548
FR-Designer_Move_Up=\u4E0A\u79FB\u4E00\u5C42(F)
FR-Designer_Move_Down=\u4E0B\u79FB\u4E00\u5C42(B)
FR-Designer_Move_To_Top=\u7F6E\u4E8E\u9876\u5C42(T)
FR-Designer_Move_To_Bottom=\u7F6E\u4E8E\u5E95\u5C42(K)
FR-Designer_Tab_Style_Template=\u6837\u5F0F\u6A21\u677F
FR-Designer_Tab_Template_One=\u6A21\u677F\u4E00
FR-Designer_Tab_Template_Two=\u6A21\u677F\u4E8C
FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09
FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB
FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94
FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D
FR-Designer_Tab_Display_Position=\u663E\u793A\u4F4D\u7F6E

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

@ -2148,3 +2148,18 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=\u82E5\u555F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8B49\u66F8\u8DEF\u5F91\u3001https\u7955\u9470\uFF09\uFF0C\u5FC5\u9808\u91CD\u555F\u8A2D\u8A08\u5668\u624D\u80FD\u751F\u6548\u3002
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Preference_CachingTemplate=\u7BC4\u672C\u8A18\u61B6\u9AD4\u512A\u5316
FR-Designer_Preference_MaxCachingTemplate=\u8A2D\u8A08\u5668\u6700\u5927\u7DE9\u5B58\u7BC4\u672C\u500B\u6578\uFF1A
FR-Designer_Preference_CachingTemplateTip=\u8A2D\u5B9A\u70BA0\u8868\u793A\u95DC\u9589\u8A72\u529F\u80FD\uFF1B\u91CD\u5553\u8A2D\u8A08\u5668\u5F8C\u751F\u6548
FR-Designer_Move_Up=\u4E0A\u79FB\u4E00\u5C64(F)
FR-Designer_Move_Down=\u4E0B\u79FB\u4E00\u5C64(B)
FR-Designer_Move_To_Top=\u7F6E\u65BC\u9802\u5C64(T)
FR-Designer_Move_To_Bottom=\u7F6E\u65BC\u5E95\u5C64(K)
FR-Designer_Tab_Style_Template=\u6A23\u5F0F\u6A21\u677F
FR-Designer_Tab_Template_One=\u6A21\u677F\u4E00
FR-Designer_Tab_Template_Two=\u6A21\u677F\u4E8C
FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09
FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB
FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94
FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D
FR-Designer_Tab_Display_Position=\u986F\u793A\u4F4D\u7F6E

2
designer_base/src/com/fr/design/mainframe/DesignerFrame.java

@ -911,8 +911,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} else {
this.addAndActivateJTemplate(jt);
}
//REPORT-5084:激活后刷新一下右側面板
jt.refreshEastPropertiesPane();
}
/**

50
designer_base/src/com/fr/design/mainframe/JSliderPane.java

@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ibutton.UISliderButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.ispinner.UISpinnerUI;
@ -19,11 +20,14 @@ import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicSliderUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
/**
@ -31,25 +35,19 @@ import java.math.BigDecimal;
*/
public class JSliderPane extends JPanel {
public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png");
private static final double ONEPOINTEIGHT = 1.8;
private static final int SIX = 6;
private static final int TEN = 10;
private static final int ONE_EIGHT = 18;
private static final int FONT_SIZE = 12;
private static final int SPINNER_WIDTH = 45;
private static final int SPINNER_HEIGHT = 20;
private static final int HALF_HUNDRED = 50;
private static final int HUNDRED = 100;
private static final int TWO_HUNDRED = 200;
private static final int THREE_HUNDRED = 300;
private static final int FOUR_HUNDRED = 400;
private static final int DIALOG_WIDTH = 157;
private static final int DIALOG_HEIGHT = 192;
private static final int SLIDER_WIDTH = 220;
private static final int SLIDER_HEIGHT = 20;
private static final int SHOWVALBUTTON_WIDTH = 40;
private static final int SHOWVALBUTTON_HEIGHTH = 20;
private static final int SLIDER_GAP = 5;
private static final int TOOLTIP_Y = 30;
private static final Color BACK_COLOR = new Color(245, 245, 247);
@ -405,14 +403,14 @@ public class JSliderPane extends JPanel {
dialog = new PopupPane(upButton, dialogContentPanel);
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height);
}
} else {
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height);
} else {
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height);
}
}
}
@ -433,8 +431,8 @@ public class JSliderPane extends JPanel {
class JSliderPaneUI extends BasicSliderUI {
private static final Color BACK_COLOR = new Color(245, 245, 247);
private static final int VERTICAL_WIDTH = 11;
private static final int VERTICAL_HEIGHT = 16;
private static final int THUMB_XOFFSET = 8;
private static final int THUMB_YOFFSET = 3;
private static final int FOUR = 4;
private static final int FIVE = 5;
private static final int SIX = 6;
@ -451,13 +449,9 @@ class JSliderPaneUI extends BasicSliderUI {
public void paintThumb(Graphics g) {
Rectangle knobBounds = thumbRect;
int w = knobBounds.width;
int h = knobBounds.height;
Graphics2D g2d = (Graphics2D) g;
g2d.translate(knobBounds.x, knobBounds.y);
g2d.setColor(new Color(51, 51, 52));
g2d.fillRoundRect(0, SIX, FOUR, 9, 2, 2);
g2d.drawImage(JSliderPane.APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null);
g2d.dispose();
}
/** */
@ -481,11 +475,19 @@ class JSliderPaneUI extends BasicSliderUI {
}
}
public void setThumbLocation(int x, int y) {
super.setThumbLocation(x, y);
slider.repaint();
}
}
class PopupPane extends JPopupMenu {
class PopupPane extends UIPopupMenu {
private static final float REC = 8f;
private static final int INSERT_TOPBOTTOM = 10;
private static final int INSERT_LEFTRIGHT = 2;
private static final int DIALOG_WIDTH = 157;
private static final int DIALOG_HEIGHT = 192;
private static final int DIALOG_HEIGHT = 205;
PopupPane(JButton b, JPanel dialogContentPanel) {
this.add(dialogContentPanel, BorderLayout.CENTER);
@ -493,5 +495,7 @@ class PopupPane extends JPopupMenu {
this.setBackground(new Color(245, 245, 247));
}
public Insets getInsets() {
return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT);
}
}

6
designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java

@ -12,9 +12,8 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.file.FILE;
import com.fr.file.FileFILE;
import com.fr.file.FileNodeFILE;
import com.fr.stable.StableUtils;
import com.fr.stable.OperatingSystem;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
@ -40,7 +39,8 @@ public class JVirtualTemplate extends JTemplate {
if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName;
}
return editingFileName.replaceAll("/", "\\\\");
editingFileName = OperatingSystem.isWindows() ? editingFileName.replaceAll("/", "\\\\") : editingFileName.replaceAll("\\\\", "/");
return editingFileName;
}
/**

1
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -180,6 +180,7 @@ public abstract class ToolBarMenuDock {
this.menus = menus(plus);
for (int i = 0; i < menus.length; i++) {
menus[i].setHasRecMenu(true);
UIMenu subMenu = menus[i].createJMenu();
jMenuBar.add(subMenu);
menus[i].updateMenu();

14
designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java

@ -27,12 +27,18 @@ public class UpdateActionManager {
this.updateActions = updateActions;
}
public boolean isEnable(UpdateAction updateAction) {
/**
* 根据action name获取action对象
*
* @param name
* @return
*/
public UpdateAction getActionByName(String name) {
for (UpdateActionModel action : updateActions) {
if (ComparatorUtils.equals(updateAction.getName(), action.getActionName()) && action.getAction().isEnabled()) {
return true;
if (ComparatorUtils.equals(name, action.getActionName()) && action.getAction().isEnabled()) {
return action.getAction();
}
}
return false;
return null;
}
}

42
designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java

@ -0,0 +1,42 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.design.mainframe.widget.wrappers.TemplateStyleWrapper;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
/**
* Created by kerry on 2017/11/23.
*/
public class AccessibleTemplateStyleEditor extends UneditableAccessibleEditor {
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400);
private TemplateStylePane stylePane;
public AccessibleTemplateStyleEditor() {
super(new TemplateStyleWrapper());
}
@Override
protected void showEditorPane() {
if (stylePane == null) {
stylePane = new TemplateStylePane();
stylePane.setPreferredSize(DEFAULT_DIMENSION);
}
BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(stylePane.update());
fireStateChanged();
}
});
stylePane.populate((TemplateStyle) getValue());
dlg.setVisible(true);
}
}

99
designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java

@ -0,0 +1,99 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.general.cardtag.BannerTemplateStyle;
import com.fr.general.cardtag.BookMarkTemplateStyle;
import com.fr.general.cardtag.CardTemplateStyle;
import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.MenuTemplateStyle;
import com.fr.general.cardtag.PentagonTemplateStyle;
import com.fr.general.cardtag.TrapezoidTemplateStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created by kerry on 2017/11/23.
*/
public class TemplateStylePane extends BasicPane {
private DefaultListModel listModel;
private JList styleList;
private TemplateStylePreviewPane previewPane = new TemplateStylePreviewPane(new DefaultTemplateStyle());
public TemplateStylePane(){
init();
}
public void init(){
this.setLayout(FRGUIPaneFactory.createBorderLayout());
listModel = new DefaultListModel();
listModel.addElement(new DefaultTemplateStyle());
listModel.addElement(new CardTemplateStyle());
listModel.addElement(new BookMarkTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new MenuTemplateStyle());
listModel.addElement(new TrapezoidTemplateStyle());
listModel.addElement(new BannerTemplateStyle());
styleList = new JList(listModel);
styleList.setCellRenderer(render);
JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
westPane.add(styleList, BorderLayout.CENTER);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
westPane.setPreferredSize(new Dimension(100, 500));
centerPane.setPreferredSize(new Dimension(300, 500));
centerPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Preview"), null));
centerPane.add(previewPane);
styleList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
previewPane.repaint((TemplateStyle) styleList.getSelectedValue());
}
});
this.add(westPane, BorderLayout.WEST);
this.add(centerPane, BorderLayout.CENTER);
}
public static ListCellRenderer render = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof TemplateStyle) {
TemplateStyle l = (TemplateStyle) value;
this.setText(l.toString());
}
return this;
}
};
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Tab_Style_Template");
}
public void populate(TemplateStyle templateStyle) {
previewPane.repaint(templateStyle);
for(int i = 0; i< listModel.getSize(); i++){
if((listModel.getElementAt(i).toString()).equals(templateStyle.toString())){
styleList.setSelectedIndex(i);
return;
}
}
styleList.setSelectedIndex(0);
}
public TemplateStyle update() {
return (TemplateStyle) styleList.getSelectedValue();
}
}

37
designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.base.BaseUtils;
import com.fr.general.cardtag.TemplateStyle;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
/**
* Created by kerry on 2017/12/11.
*/
public class TemplateStylePreviewPane extends JPanel {
private static final int WIDTH = 540;
private static final int HEIGHT = 500;
private TemplateStyle templateStyle;
public TemplateStylePreviewPane(TemplateStyle templateStyle){
this.templateStyle = templateStyle;
}
public void repaint (TemplateStyle templateStyle){
this.templateStyle = templateStyle;
super.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g.create();
Image image = BaseUtils.readImage(templateStyle.getPreview());
g2d.drawImage(image, 0, 0, WIDTH, HEIGHT, null);
}
}

29
designer_base/src/com/fr/design/mainframe/widget/wrappers/TemplateStyleWrapper.java

@ -0,0 +1,29 @@
package com.fr.design.mainframe.widget.wrappers;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.stable.StringUtils;
/**
* Created by kerry on 2017/11/23.
*/
public class TemplateStyleWrapper implements Encoder, Decoder {
@Override
public String encode(Object v) {
if (v == null) {
return StringUtils.EMPTY;
}
return v.toString();
}
@Override
public Object decode(String txt) {
return null;
}
@Override
public void validate(String txt) throws ValidationException {
}
}

12
designer_base/src/com/fr/design/menu/MenuDef.java

@ -2,10 +2,7 @@ package com.fr.design.menu;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.gui.imenu.UIPopupEastAttrMenu;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.imenu.UIScrollMenu;
import com.fr.design.gui.imenu.*;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
@ -41,6 +38,7 @@ public class MenuDef extends ShortCut {
protected UIButton createdButton;
protected JPopupMenu popupMenu;
private boolean hasScrollSubMenu;
private boolean isHeadMenu;
private String anchor;
@ -88,6 +86,10 @@ public class MenuDef extends ShortCut {
this.hasScrollSubMenu = scrollSubMenu;
}
public void setHasRecMenu(boolean headMenu) {
this.isHeadMenu = headMenu;
}
public String getIconPath() {
return iconPath;
}
@ -186,6 +188,8 @@ public class MenuDef extends ShortCut {
if (createdJMenu == null) {
if (hasScrollSubMenu) {
createdJMenu = new UIScrollMenu(this.getName());
} else if (isHeadMenu){
createdJMenu = new UIHeadMenu(this.getName());
} else {
createdJMenu = new UIMenu(this.getName());
}

2
designer_base/src/com/fr/design/utils/ThemeUtils.java

@ -13,7 +13,7 @@ import java.awt.*;
*/
public class ThemeUtils {
public static final ColorUIResource NORMAL_FOREGROUND = new ColorUIResource(0, 0, 0);
public static final ColorUIResource TEXT_SELECTED_BG_COLOR = new ColorUIResource(43, 107, 197);
public static final ColorUIResource TEXT_SELECTED_BG_COLOR = new ColorUIResource(65, 155, 249);
public static final ColorUIResource TEXT_SELECTED_TEXT_COLOR = new ColorUIResource(255, 255, 255);
public static final ColorUIResource NORMAL_BG = new ColorUIResource(212, 212, 216);
public static final ColorUIResource DISABLE_TEXT = new ColorUIResource(143, 142, 139);

37
designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java

@ -5,6 +5,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants;
import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.geom.RoundRectangle2D;
public class GUIPaintUtils {
@ -202,4 +203,40 @@ public class GUIPaintUtils {
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
/**
* 自定义popMenu画法,一种下面两圆角矩形
*
*/
public static final Shape paintShape(Graphics2D g2, float width, float height, float REC) {
REC = REC / 2;
float recdir = (float) (REC - (REC / Math.sqrt(2)));
GeneralPath gp1 = new GeneralPath();
gp1.moveTo(0f, 0f);
gp1.lineTo(width, 0f);
gp1.lineTo(width, height - REC);
gp1.quadTo(width - recdir, height - recdir, width - REC, height);
gp1.lineTo(REC, height);
gp1.quadTo(recdir, height - recdir, 0, height - REC);
gp1.closePath();
return gp1;
}
/**
* 自定义popMenu边框画法,一种下面两圆角矩形
*
*/
public static final void paintShapeBorder(Graphics2D g2, int x, int y, int width, int height, int rec) {
g2.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
width = width - 1;
height = height - 1;
rec = rec / 2;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2.drawLine(x, y, x + width, y);
g2.drawLine(x + width, y, x + width, y + height - rec);
g2.drawArc(x + width - (rec / 2), y + height - (rec / 2), rec / 2, rec / 2, 0, 90);
g2.drawLine(x + width - rec, y + height, x + rec, y + height);
g2.drawArc(x - (rec / 2), y + height - (rec / 2), rec / 2, rec / 2, 0, 90);
g2.drawLine(x, y + height - rec, x, y);
}
}

24
designer_base/src/com/fr/design/widget/WidgetBoundsPaneFactory.java

@ -9,8 +9,11 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by plough on 2017/8/7.
@ -69,4 +72,21 @@ public class WidgetBoundsPaneFactory {
boundsPane.add(centerPanel, BorderLayout.CENTER);
return new UIExpandablePane(Inter.getLocText("FR-Designer_Coords_And_Size"), 230, 24, boundsPane);
}
public static UIExpandablePane createCardTagBoundPane(UISpinner width) {
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Size")), width},
};
double[] rowSize = {p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}};
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L6);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
boundsPane.add(panel);
return new UIExpandablePane(Inter.getLocText("FR-Designer_Coords_And_Size"), 280, 24, boundsPane);
}
}

83
designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java

@ -5,7 +5,7 @@ package com.fr.design.designer.beans.actions;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.general.Inter;
@ -19,44 +19,45 @@ import com.fr.design.mainframe.FormSelection;
*/
public class FormDeleteAction extends FormUndoableAction {
public FormDeleteAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("M_Edit-Delete"));
this.setMnemonic('D');
// Richie:删除菜单图标
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
}
/**
* 删除
*
* @return 是否删除成功
*/
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
designer.getSelectionModel().deleteSelection();
creator.deleteRelatedComponent(creator, designer);
return false;
}
@Override
public void update() {
// FormDesigner f = this.getEditingComponent();
// if (f == null) {
// this.setEnabled(false);
// return;
// }
// SelectionModel selection = f.getSelectionModel();
// this.setEnabled(selection.hasSelectionComponent());
this.setEnabled(true);
}
public FormDeleteAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("M_Edit-Delete"));
this.setMnemonic('D');
// Richie:删除菜单图标
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
}
@Override
public JComponent createToolBarComponent() {
JComponent comp = super.createToolBarComponent();
// 除了 BACKSPACE 之外,DELETE 键也要能删除(直接在此处添加绑定,没有按钮提示)
comp.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
return comp;
}
/**
* 删除
*
* @return 是否删除成功
*/
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
designer.getSelectionModel().deleteSelection();
creator.deleteRelatedComponent(creator, designer);
return false;
}
@Override
public void update() {
this.setEnabled(true);
}
}

59
designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java

@ -0,0 +1,59 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 下移一层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveDownAction extends FormEditAction {
public MoveDownAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_Down"));
this.setMnemonic('B');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
int targetIndex = container.getComponentZOrder(creator) + 1;
if (targetIndex >= container.getComponentCount()) {
return false;
}
container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableDown());
}
}

60
designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java

@ -0,0 +1,60 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 置于底层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveToBottomAction extends FormEditAction {
public MoveToBottomAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_To_Bottom"));
this.setMnemonic('K');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_bottom.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
int targetIndex = container.getComponentCount() - 1;
if (container.getComponentZOrder(creator) >= targetIndex) {
return false;
}
container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableDown());
}
}

59
designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java

@ -0,0 +1,59 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 置于顶层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveToTopAction extends FormEditAction {
public MoveToTopAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_To_Top"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_top.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
if (container.getComponentZOrder(creator) == 0) {
return false;
}
container.setComponentZOrder(creator, 0);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableUp());
}
}

59
designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java

@ -0,0 +1,59 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 同级上移一层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveUpAction extends FormEditAction {
public MoveUpAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_Up"));
this.setMnemonic('F');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
int targetIndex = container.getComponentZOrder(creator) - 1;
if (targetIndex < 0) {
return false;
}
container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableUp());
}
}

4
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java

@ -4,6 +4,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.general.ComparatorUtils;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
@ -35,6 +36,9 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
* @param creator 组件
*/
public void fix(XCreator creator) {
if(creator.acceptType(XWCardTagLayout.class)){
creator = (XCreator) creator.getParent();
}
FRBorderLayout layout = (FRBorderLayout)container.getFRLayout();
Object constraints = layout.getConstraints(creator);
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) {

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

@ -13,6 +13,7 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRFitLayoutConstraints;
import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel;
@ -20,10 +21,13 @@ 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.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
@ -281,9 +285,22 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
backupBound.y -= rec.y;
XWCardLayout cardLayout = mainLayout.getCardPart();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart();
Dimension titleDimension = xwCardTitleLayout.getSize();
// 当tab布局为标题样式时,才需要处理标题栏高度产生的影响
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
backupBound.y -= WCardMainBorderLayout.TAB_HEIGHT;
WTabDisplayPosition wTabDisplayPosition = xwCardTitleLayout.getDisplayPosition();
switch (wTabDisplayPosition){
case TOP_POSITION:
backupBound.y -= titleDimension.height;
break;
case LEFT_POSITION:
backupBound.x -= titleDimension.width;
break;
default:
return backupBound;
}
}
return backupBound;
}

2
designer_form/src/com/fr/design/designer/beans/events/DesignerEvent.java

@ -23,6 +23,8 @@ public class DesignerEvent {
public static final int CREATOR_RENAMED = 8;
public static final int CREATOR_ORDER_CHANGED = 9;
private int eventID;
private XComponent affectedXCreator;

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

@ -62,13 +62,16 @@ public class SelectionModel {
* @param e 鼠标事件
*/
public void selectACreatorAtMouseEvent(MouseEvent e) {
if (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown()) {
if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) {
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
selection.reset();
}
// 获取e所在的组件
XCreator comp = designer.getComponentAt(e);
selectACreator(comp);
}
public void selectACreator(XCreator comp) {
//布局组件的顶层布局如不可编辑,要获取其顶层布局
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
if (topLayout != null && !topLayout.isEditable()) {
@ -78,7 +81,9 @@ public class SelectionModel {
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
XCreator parentContainer = (XCreator) comp.getParent();
comp = parentContainer.isDedicateContainer() ? parentContainer : comp;
if (parentContainer != null) {
comp = parentContainer.isDedicateContainer() ? parentContainer : comp;
}
}
if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) {
designer.getEditListenerTable().fireCreatorModified(comp, DesignerEvent.CREATOR_SELECTED);

3
designer_form/src/com/fr/design/designer/beans/painters/FRBorderLayoutPainter.java

@ -18,6 +18,9 @@ public class FRBorderLayoutPainter extends AbstractPainter {
@Override
public void paint(Graphics g, int startX, int startY) {
if(hotspot_bounds == null){
return;
}
super.paint(g, startX, startY);
int x = hotspot.x;
int y = hotspot.y;

8
designer_form/src/com/fr/design/designer/creator/XChartEditor.java

@ -76,6 +76,11 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return true;
}
@Override
public void stopEditing() {
isEditing = false;
}
/**
* 得到属性名
* @return 属性名
@ -201,7 +206,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
isEditing = e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR;
isEditing = e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR);
displayCoverPane(!isEditing);
selectionModel.selectACreatorAtMouseEvent(e);

37
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -4,11 +4,13 @@
package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.*;
import com.fr.design.utils.gui.LayoutUtils;
@ -47,8 +49,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
private Rectangle backupBound;
private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性
private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上
private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置
public XCreator(Widget ob, Dimension initSize) {
public XCreator(Widget ob, Dimension initSize) {
this.data = ob;
this.initEditor();
@ -653,7 +656,39 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
*
*/
public void firePropertyChange(){
// do nothing
}
/**
* 有的控件是有编辑状态的给一个退出编辑的接口
*
*/
public void stopEditing() {
// do nothing
}
/**
* 创建右击弹出菜单
*
*/
public JPopupMenu createPopupMenu(FormDesigner formDesigner) {
UpdateAction[] actions = formDesigner.getActions();
JPopupMenu popup = new UIPopupMenu();
for (int i = 0; i < actions.length; i++) {
if (i == SHORTS_SEPARATOR_POS) {
popup.addSeparator();
}
popup.add(actions[i].createMenuItem());
}
return popup;
}
/**
* 是否支持上移一层下移一层等操作
*
*/
public boolean isMovable() {
return true;
}
}

3
designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java

@ -237,6 +237,9 @@ public class XCreatorUtils {
Container c = creator.getParent();
while (c != null) {
XCreator crea = (XCreator) c;
if(crea.acceptType(XWCardTitleLayout.class)){
return (XLayoutContainer) c.getParent();
}
if (crea.isDedicateContainer()) {
return (XLayoutContainer) c.getParent();
}

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

@ -122,7 +122,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
if (editor.getFitStateInPC() == 0) {
editor.setReportFitAttr(null);
}
ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : editor.getReportFitAttr();
ReportFitAttrProvider reportFit = editor.getReportFitAttr();
if(fitAttr != null){
reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr;
}
ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit;
PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr);
if (editor.getReportFitAttr() == null) {
editor.setReportFitInPc(processor.getFitStateInPC(fitAttr));
@ -302,7 +306,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){
FormDesigner designer = editingMouseListener.getDesigner();
if (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR){
if (e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)){
FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e);
//切换设计器
designer.switchTab(component);

4
designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -107,5 +107,9 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
initStyle();
}
@Override
public boolean isMovable() {
return false;
}
}

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

@ -467,7 +467,8 @@ public class XWAbsoluteLayout extends XLayoutContainer {
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;
boolean isEditing = isEditable() ||
e.getButton() == MouseEvent.BUTTON1 && (designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2);
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);

4
designer_form/src/com/fr/design/designer/creator/XWFitLayout.java

@ -1181,4 +1181,8 @@ public class XWFitLayout extends XLayoutContainer {
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)};
}
@Override
public boolean isMovable() {
return false;
}
}

25
designer_form/src/com/fr/design/designer/creator/XWHorizontalBoxLayout.java

@ -8,8 +8,7 @@ import java.awt.Dimension;
import java.awt.event.ContainerEvent;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.form.layout.FRFlowLayout;
import com.fr.design.form.layout.FRHorizontalLayout;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WHorizontalBoxLayout;
@ -20,6 +19,16 @@ import com.fr.form.ui.container.WHorizontalBoxLayout;
*/
public class XWHorizontalBoxLayout extends XLayoutContainer {
public FRFlowLayout getFrFlowLayout() {
return frFlowLayout;
}
public void setFrFlowLayout(FRFlowLayout frFlowLayout) {
this.frFlowLayout = frFlowLayout;
}
private FRFlowLayout frFlowLayout ;
public XWHorizontalBoxLayout(WHorizontalBoxLayout widget, Dimension initSize) {
super(widget, initSize);
}
@ -46,7 +55,8 @@ public class XWHorizontalBoxLayout extends XLayoutContainer {
@Override
protected void initLayoutManager() {
this.setLayout(new FRHorizontalLayout(toData().getAlignment(), toData().getHgap(), toData().getVgap()));
this.frFlowLayout = new FRHorizontalLayout(toData().getAlignment(), toData().getHgap(), toData().getVgap());
this.setLayout(frFlowLayout);
}
@Override
@ -60,7 +70,7 @@ public class XWHorizontalBoxLayout extends XLayoutContainer {
for (int i = 0, count = this.getComponentCount(); i < count; i++) {
if (creator == this.getComponent(i)) {
wlayout.addWidget(wgt, i);
wlayout.setWidthAtWidget(wgt, creator.getWidth());
frFlowLayout.componentAdded(e, wlayout);
}
}
this.recalculateChildrenPreferredSize();
@ -70,7 +80,7 @@ public class XWHorizontalBoxLayout extends XLayoutContainer {
protected Dimension calculatePreferredSize(Widget wgt) {
// 注意这里计算PreferredSize的时候需要取当前容器的实际大小
// 高度是自适应的,直接就写成0了
return new Dimension(this.toData().getWidthAtWidget(wgt), 0);
return frFlowLayout.calculatePreferredSize(this.toData(), wgt);
}
// 在添加的时候需要把可拉伸的方向确定,所以重写了add方法
@ -80,13 +90,12 @@ public class XWHorizontalBoxLayout extends XLayoutContainer {
if (comp == null) {
return null;
}
XCreator creator = (XCreator) comp;
creator.setDirections(new int[]{Direction.LEFT, Direction.RIGHT});
frFlowLayout.setDirections(comp);
return comp;
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRHorizontalLayoutAdapter(this);
return frFlowLayout.getLayoutAdapter(this);
}
}

5
designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java

@ -227,4 +227,9 @@ public class XWParameterLayout extends XWAbsoluteLayout {
}
@Override
public boolean isMovable() {
return false;
}
}

8
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -1,6 +1,9 @@
package com.fr.design.designer.creator.cardlayout;
import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
@ -106,7 +109,7 @@ public class XCardAddButton extends XButton{
FormHierarchyTreePane.getInstance().refreshRoot();
//将焦点切换到新增的tab对应的tabfitLayout上
showNewTab(editingMouseListener,index);
tagLayout.setTabsAndAdjust();
LayoutUtils.layoutRootContainer(designer.getRootComponent());
}
@ -151,7 +154,6 @@ public class XCardAddButton extends XButton{
titleButton.setCustomStyle(true);
titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout);
this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index);
this.tagLayout.add(showButton);

113
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -4,13 +4,12 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ilable.UILabel;
@ -23,17 +22,26 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WTabTextDirection;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.util.HashMap;
import java.util.Map;
/**
*
@ -65,8 +73,6 @@ public class XCardSwitchButton extends XButton {
// tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量
private static final int FONT_SIZE_ADJUST = 2;
private static final int SIDE_OFFSET = 57;
private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout;
@ -118,6 +124,7 @@ public class XCardSwitchButton extends XButton {
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) {
super(widget, initSize);
}
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize,
@ -180,7 +187,6 @@ public class XCardSwitchButton extends XButton {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter);
}
setTabsAndAdjust();
if(SwingUtilities.isRightMouseButton(e)){
showPopupMenu(editingMouseListener, e, index, maxIndex);
}
@ -211,7 +217,7 @@ public class XCardSwitchButton extends XButton {
private void deleteCard(XCardSwitchButton button,int index){
String titleName = button.getContentLabel().getText();
int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”",
Inter.getLocText("FR-Designer_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION);
Inter.getLocText("FR-Designer_ConfirmDialog_Title"), JOptionPane.YES_NO_OPTION);
if (value != JOptionPane.OK_OPTION) {
return;
}
@ -296,7 +302,6 @@ public class XCardSwitchButton extends XButton {
public void paintComponent(Graphics g) {
super.paintComponent(g);
setTabsAndAdjust();
Graphics2D g2d = (Graphics2D) g;
drawBackground();
drawTitle();
@ -334,7 +339,22 @@ public class XCardSwitchButton extends XButton {
//画标题
private void drawTitle() {
CardSwitchButton button = (CardSwitchButton) this.toData();
this.setButtonText(button.getText());
String titleText = button.getText();
if(tagLayout != null){
WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData();
StringBuilder titleString = new StringBuilder();
//竖向处理
if(ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)){
titleString.append("<html>");
for(int i = 0; i < titleText.length(); i++){
titleString.append(titleText.charAt(i)).append("<br/>");
}
titleString.append("</html>");
titleText = titleString.toString();
}
}
this.setButtonText(titleText);
if (this.cardLayout == null) {
initRelateLayout(this);
}
@ -384,63 +404,36 @@ public class XCardSwitchButton extends XButton {
return this.getBackupParent().getTopLayout();
}
public void setTabsAndAdjust() {
if (this.tagLayout == null) {
return;
}
int tabLength = this.tagLayout.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<>();
Map<Integer, Integer> cardHeight = new HashMap<>();
for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
String tempText = tempCard.getText();
Font f = tempCard.getFont();
FontMetrics fm = GraphHelper.getFontMetrics(f);
cardWidth.put(i,fm.stringWidth(tempText));
cardHeight.put(i,fm.getHeight());
}
adjustTabs(tabLength, cardWidth, cardHeight);
}
public void adjustTabs(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
int tempX = 0;
for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.tagLayout.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + SIDE_OFFSET;
//先用这边的固定高度
Integer cardHeight = DEFAULT_BUTTON_HEIGHT;
rectangle.setSize(cardWidth, cardHeight);
rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth;
this.tagLayout.getComponent(i).setBounds(rectangle);
Dimension dimension = new Dimension();
dimension.setSize(cardWidth, cardHeight);
XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i);
CardSwitchButton cardSwitchButton = (CardSwitchButton) temp.toData();
FRFont frFont = cardSwitchButton.getFont();
UILabel label = temp.getContentLabel();
label.setSize(dimension);
label.setFont(frFont.applyResolutionNP(ScreenResolution.getScreenResolution()));
label.setForeground(frFont.getForeground());
temp.setContentLabel(label);
temp.setSize(dimension);
temp.setPreferredSize(new Dimension(cardWidth, cardHeight));
}
}
@Override
public void doLayout() {
super.doLayout();
setTabsAndAdjust();
}
/**
* 控件树里需要隐藏xwcardmainLayout返回其子组件xwcardLayout
* 标题样式下this.getComponent(1)==xwcardLayout
* 标准样式下this.getComponent(0)==xwcardLayout
* @return 子组件xwcardLayout
*/
@Override
public XCreator getXCreator() {
//根据index获取对应的tabFitLayout
int index = ((CardSwitchButton) this.toData()).getIndex();
return (XCreator) cardLayout.getComponent(index);
}
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
label = this.getContentLabel();
}
public void firePropertyChange() {
super.firePropertyChange();
tagLayout.setTabsAndAdjust();
repaint();
}
}

26
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -8,7 +8,11 @@ import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRCardLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.form.layout.FRCardLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.FormDesigner;
@ -16,7 +20,11 @@ import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.BooleanEditor;
import com.fr.design.mainframe.widget.editors.CardTagWLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.editors.DoubleEditor;
import com.fr.form.ui.*;
import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WLayout;
@ -30,7 +38,9 @@ import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ContainerEvent;
import java.beans.IntrospectionException;
@ -67,7 +77,7 @@ public class XWCardLayout extends XLayoutContainer {
*
*/
public String createDefaultName() {
return "tabpane";
return "cardlayout";
}
/**
@ -146,10 +156,12 @@ public class XWCardLayout extends XLayoutContainer {
//主结构是一个borderlayout, 标签部分是north, card部分为center
WCardMainBorderLayout border = new WCardMainBorderLayout();
XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension);
//将子WCardBorder的style设置到父容器上
LayoutBorderStyle style = (this.toData()).getBorderStyle();
border.setBorderStyle(style);
this.setBackupParent(xMainBorder);
XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder);
xMainBorder.addTitlePart(titlePart);
xMainBorder.addTitlePart(titlePart, WBorderLayout.NORTH);
return xMainBorder;
}
@ -188,7 +200,7 @@ public class XWCardLayout extends XLayoutContainer {
private XWCardTagLayout initTagPart(String widgetName, XWCardTitleLayout xTitle){
Dimension dimension = new Dimension();
//放置标题的tab流式布局
WCardTagLayout tagLayout = new WCardTagLayout();
WCardTagLayout tagLayout = new WCardTagLayout("tabpane" + widgetName.replaceAll(createDefaultName(), ""));
XWCardTagLayout xTag = new XWCardTagLayout(tagLayout, dimension, this);
xTag.setBackupParent(xTitle);

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

@ -15,12 +15,18 @@ 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.WTabDisplayPosition;
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.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
@ -73,10 +79,26 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* @date 2014-12-10-下午1:50:56
*
*/
public void addTitlePart(XWCardTitleLayout title){
this.add(title, WBorderLayout.NORTH);
public void addTitlePart(XWCardTitleLayout title, String position){
toData().setTabPosition(position);
this.add(title, position);
}
public void add(Component comp, String position) {
super.add(comp, position);
}
/**
* 切换到非添加状态
*
* @return designer 表单设计器
*/
public void stopAddingState(FormDesigner designer){
designer.stopAddingState();
return;
}
/**
* 添加card区域
*
@ -95,6 +117,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
}
public XWCardTitleLayout getTitlePart(){
Component[] components = this.getComponents();
for(Component component : components){
if(component instanceof XWCardTitleLayout){
return (XWCardTitleLayout)component;
}
}
return (XWCardTitleLayout)this.getComponent(NORTH);
}
@ -106,15 +134,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
*/
@Override
public XCreator getXCreator() {
switch(this.getComponentCount()){
case TITLE_STYLE:
return (XCreator)this.getComponent(TITLE_STYLE-1);
case NORMAL_STYLE:
return (XCreator)this.getComponent(NORMAL_STYLE-1);
default:
return this;
}
return this;
}
/**
* 控件树不显示此组件
* @param path 控件树list
@ -246,7 +268,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2;
boolean isEditing = e.getButton() == MouseEvent.BUTTON1 &&
(designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2);
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
@ -274,4 +297,35 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
return this;
}
}
/**
* data属性改变触发其他操作
*
*/
public void firePropertyChange(){
getCardPart().initStyle();
}
public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){
XWCardTitleLayout xwCardTitleLayout = getTitlePart();
xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition);
switch (wTabDisplayPosition){
case TOP_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.NORTH);
break;
case LEFT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.WEST);
break;
case BOTTOM_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.SOUTH);
break;
case RIGHT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.EAST);
break;
default:
break;
}
this.addCardPart((XWCardLayout)this.getComponent(0));
}
}

239
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -3,26 +3,47 @@
*/
package com.fr.design.designer.creator.cardlayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.swing.border.Border;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.form.layout.FRFlowLayout;
import com.fr.design.form.layout.FRHorizontalLayout;
import com.fr.design.form.layout.FRVerticalLayout;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
/**
* @date: 2014-11-25-下午3:11:14
@ -39,6 +60,12 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
private int tabFitIndex = 0;
private CardSwitchButton currentCard;
private static final int WIDTH_SIDE_OFFSET = 57;
private static final int HEIGHT_SIDE_OFFSET = 20;
private static final int DEFAULT_BUTTON_HEIGHT = 40;
public CardSwitchButton getCurrentCard() {
return currentCard;
}
@ -75,14 +102,14 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
public XWCardTagLayout(WCardTagLayout widget, Dimension initSize) {
super(widget, initSize);
initLayoutManager();
}
/**
* 构造函数
*/
public XWCardTagLayout(WCardTagLayout widget, Dimension initSize, XWCardLayout cardLayout) {
super(widget, initSize);
this(widget, initSize);
this.cardLayout = cardLayout;
}
@ -109,19 +136,20 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard);
fitLayout.setTabNameIndex(getTabNameIndex());
XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension());
tabFitLayout.setxCardSwitchButton((XCardSwitchButton)this.getComponent(0));
tabFitLayout.setBackupParent(cardLayout);
cardLayout.add(tabFitLayout, widgetName);
this.cardLayout.toData().setShowIndex(index);
cardLayout.showCard();
}
private void initCardLayout() {
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent();
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent();
this.cardLayout = borderLayout.getCardPart();
}
/**
* 将WLayout转换为XLayoutContainer
*/
@ -132,6 +160,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
for (int i = 0; i < layout.getWidgetCount(); i++) {
Widget wgt = layout.getWidget(i);
if (wgt != null) {
initLayoutManager();
XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(wgt, calculatePreferredSize(wgt));
this.add(comp, i);
comp.setBackupParent(this);
@ -140,6 +169,10 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
isRefreshing = false;
}
public String createDefaultName() {
return "tabpane";
}
/**
* 切换到非添加状态
*
@ -195,15 +228,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent();
if (titleLayout != null) {
XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent();
if (mainLayout != null) {
XWCardLayout cardLayout = mainLayout.getCardPart();
selectionModel.setSelectedCreator(cardLayout);
}
if (e.getClickCount() <= 1) {
selectionModel.selectACreatorAtMouseEvent(e);
}
if (editingMouseListener.stopEditing()) {
if (this != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
@ -212,8 +239,198 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
}
public int[] getDirections() {
return ((XCreator)getParent()).getDirections();
}
public Rectangle getBounds() {
return this.getParent().getBounds();
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(0);
}
@Override
public void doLayout() {
//设置布局
super.doLayout();
}
@Override
protected void initLayoutManager() {
FRFlowLayout frFlowLayout;
if (isHori()) {
frFlowLayout = new FRHorizontalLayout(((WCardTagLayout)toData()).getAlignment(), toData().getHgap(), toData().getVgap());
}else{
frFlowLayout = new FRVerticalLayout(((WCardTagLayout)toData()).getAlignment(), toData().getHgap(), toData().getVgap());
}
this.setFrFlowLayout(frFlowLayout);
this.setLayout(frFlowLayout);
}
@Override
public LayoutAdapter getLayoutAdapter() {
if (isHori()) {
return new FRHorizontalLayoutAdapter(this);
}else{
return new FRVerticalLayoutAdapter(this);
}
}
private boolean isHori(){
WTabDisplayPosition displayPosition = ((WCardTagLayout)this.toData()).getDisplayPosition();
if(displayPosition == null){
displayPosition = WTabDisplayPosition.TOP_POSITION;
}
return ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION);
}
/**
* data属性改变触发其他操作
*
*/
public void firePropertyChange() {
WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData();
((XWCardMainBorderLayout) getTopLayout()).resetTabDisplayPosition(wCardTagLayout.getDisplayPosition());
//重置内部组件的大小和位置
initLayoutManager();
setTabsAndAdjust();
repaint();
}
public void setTabsAndAdjust() {
WCardTagLayout wCardTagLayout = (WCardTagLayout)this.toData();
int tabLength = this.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<>();
Map<Integer, Integer> cardHeight = new HashMap<>();
for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
String tempText = tempCard.getText();
Font f = tempCard.getFont();
FontMetrics fm = GraphHelper.getFontMetrics(f);
switch (wCardTagLayout.getTextDirection()){
case TEXT_HORI_DERECTION:
cardWidth.put(i,fm.stringWidth(tempText));
cardHeight.put(i,fm.getHeight());
break;
case TEXT_VER_DIRECTION:
int perHeight = fm.getHeight();
int wordCount = tempText.length();
if(tempText.length() !=0 ){
cardWidth.put(i,fm.stringWidth(tempText)/tempText.length());
}else {
cardWidth.put(i, 0);
}
cardHeight.put(i,(perHeight+3)*wordCount);
break;
default:
break;
}
}
if(isHori()){
adjustTabsH(tabLength, cardWidth, cardHeight);
}else {
adjustTabsV(tabLength, cardWidth, cardHeight);
}
}
public void adjustTabsH(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
//调整XWCardTagLayout的高度
int tempX = 0;
int maxHeight = DEFAULT_BUTTON_HEIGHT;
for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
Integer cardHeight = height.get(i)+ HEIGHT_SIDE_OFFSET ;
if(cardHeight < DEFAULT_BUTTON_HEIGHT){
cardHeight = DEFAULT_BUTTON_HEIGHT;
}
maxHeight = maxHeight > cardHeight ? maxHeight : cardHeight ;
rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
setTabBtnSize(cardWidth, cardHeight, temp);
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer parent = this.getBackupParent();
Rectangle parentBounds = new Rectangle(parent.getBounds());
parentBounds.height = maxHeight;
parent.setBounds(parentBounds);
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent);
if (layoutAdapter != null) {
parent.setBackupBound(parent.getBounds());
layoutAdapter.fix(parent);
}
}
public void setTabBtnSize(int cardWidth, int cardHeight, XCardSwitchButton temp){
Dimension dimension = new Dimension();
dimension.setSize(cardWidth, cardHeight);
CardSwitchButton cardSwitchButton = (CardSwitchButton) temp.toData();
FRFont frFont = cardSwitchButton.getFont();
UILabel label = temp.getContentLabel();
label.setSize(dimension);
label.setFont(frFont.applyResolutionNP(ScreenResolution.getScreenResolution()));
label.setForeground(frFont.getForeground());
temp.setContentLabel(label);
temp.setSize(dimension);
temp.setPreferredSize(new Dimension(cardWidth, cardHeight));
}
public void adjustTabsV(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
int tempY = 0;
int maxWidth = DEFAULT_BUTTON_HEIGHT;
for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
maxWidth = maxWidth > cardWidth ? maxWidth : cardWidth;
//先用这边的固定高度
Integer cardHeight = height.get(i) + HEIGHT_SIDE_OFFSET;
if(cardWidth < DEFAULT_BUTTON_HEIGHT){
cardWidth = DEFAULT_BUTTON_HEIGHT;
}
if(cardHeight < DEFAULT_BUTTON_HEIGHT){
cardHeight = DEFAULT_BUTTON_HEIGHT;
}
rectangle.setBounds(0, tempY, cardWidth, cardHeight);
tempY += cardHeight;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
setTabBtnSize(cardWidth, cardHeight, temp);
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer parent = this.getBackupParent();
Rectangle parentBounds = new Rectangle(parent.getBounds());
parentBounds.width = maxWidth;
parent.setBounds(parentBounds);
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent);
if (layoutAdapter != null) {
parent.setBackupBound(parent.getBounds());
layoutAdapter.fix(parent);
}
}
}

48
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java

@ -11,6 +11,7 @@ import javax.swing.border.Border;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
@ -19,6 +20,8 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
/**
@ -44,6 +47,11 @@ public class XWCardTitleLayout extends XWBorderLayout {
super(widget, initSize);
}
public WTabDisplayPosition getDisplayPosition(){
return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition();
}
/**
* 将WLayout转换为XLayoutContainer
*/
@ -103,6 +111,29 @@ public class XWCardTitleLayout extends XWBorderLayout {
this.add(addBtn, WBorderLayout.EAST);
}
public void resetNewBtnPosition(WTabDisplayPosition wTabDisplayPosition){
XCardAddButton xCardAddButton = (XCardAddButton) this.getComponent(0);
switch (wTabDisplayPosition){
case TOP_POSITION:
this.add(xCardAddButton, WBorderLayout.EAST);
break;
case LEFT_POSITION:
this.add(xCardAddButton, WBorderLayout.SOUTH);
break;
case BOTTOM_POSITION:
this.add(xCardAddButton, WBorderLayout.EAST);
break;
case RIGHT_POSITION:
this.add(xCardAddButton, WBorderLayout.SOUTH);
break;
default:
break;
}
//需要重新添加一次保证组件顺序不变(重新初始化CardTagLayout改变内部布局)
XWCardTagLayout xwCardTagLayout = (XWCardTagLayout) this.getComponent(0);
this.addTagPart(xwCardTagLayout);
}
/**
* 切换到非添加状态
*
@ -134,10 +165,8 @@ public class XWCardTitleLayout extends XWBorderLayout {
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) this.getBackupParent();
if(mainLayout != null){
XWCardLayout cardLayout = mainLayout.getCardPart();
selectionModel.setSelectedCreator(cardLayout);
if (e.getClickCount() <= 1) {
selectionModel.selectACreatorAtMouseEvent(e);
}
if (editingMouseListener.stopEditing()) {
@ -152,4 +181,15 @@ public class XWCardTitleLayout extends XWBorderLayout {
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
public String createDefaultName() {
return "tabpane";
}
@Override
public XCreator getXCreator() {
return (XCreator)this.getComponent(1);
}
}

23
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -1,5 +1,6 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.GraphHelper;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
@ -37,6 +38,9 @@ import java.beans.IntrospectionException;
public class XWTabFitLayout extends XWFitLayout {
private static final int MIN_SIZE = 1;
private static final int WIDTH_SIDE_OFFSET = 57;
// tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件
// 这里先将拖拽之前的宽高先做备份
private static final Color NORMAL_GRAL = new Color(236,236,236);
@ -539,6 +543,15 @@ public class XWTabFitLayout extends XWFitLayout {
public void firePropertyChange(){
checkButonType();
//根据字体长度设置tab宽度
setCardSwitchBtnSize();
XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent();
XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent();
XWCardTitleLayout titleLayout = mainLayout.getTitlePart();
// //放置tab按钮的tagLayout
XWCardTagLayout tagLayout = titleLayout.getTagPart();
tagLayout.setTabsAndAdjust();
initialBackground = ((WTabFitLayout) data).getInitialBackground();
overBackground = ((WTabFitLayout) data).getOverBackground();
clickBackground = ((WTabFitLayout)data).getClickBackground();
@ -554,4 +567,14 @@ public class XWTabFitLayout extends XWFitLayout {
cardSwitchButton.setClickBackground(clickBackground);
}
}
public void setCardSwitchBtnSize(){
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
Font f = cardSwitchButton.getFont();
FontMetrics fm = GraphHelper.getFontMetrics(f);
int width = fm.stringWidth(cardSwitchButton.getText())+ WIDTH_SIDE_OFFSET;
xCardSwitchButton.setPreferredSize(new Dimension(width, xCardSwitchButton.getHeight()));
}
}

12
designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -6,6 +6,7 @@ import java.awt.Dimension;
import javax.swing.Icon;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
@ -23,7 +24,14 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) {
setText(((XCreator) value).toData().getWidgetName());
String name = ((XCreator) value).toData().getWidgetName();
//树节点上不显示此控件
if(value instanceof XWCardLayout){
this.setSize(new Dimension(0, 0));
this.setPreferredSize(new Dimension(0, 0));
return this;
}
setText(name);
Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value);
if (icon != null) {
setIcon(icon);
@ -36,7 +44,7 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND);
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
return this;
}

24
designer_form/src/com/fr/design/form/layout/FRFlowLayout.java

@ -1,10 +1,16 @@
package com.fr.design.form.layout;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WHorizontalBoxLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.ContainerEvent;
public abstract class FRFlowLayout implements LayoutManager, FRLayoutManager, java.io.Serializable {
@ -52,6 +58,24 @@ public abstract class FRFlowLayout implements LayoutManager, FRLayoutManager, ja
protected abstract void moveComponents(Container target, Insets insets, int total);
public void componentAdded(ContainerEvent e, WHorizontalBoxLayout wlayout){
}
public Dimension calculatePreferredSize(WHorizontalBoxLayout wlayout, Widget widget){
return new Dimension();
}
public void setDirections(Component component){
}
public abstract LayoutAdapter getLayoutAdapter(XWHorizontalBoxLayout xwHorizontalBoxLayout) ;
public void adjustComponents(Component component){
}
@Override
public void addLayoutComponent(String name, Component comp) {

36
designer_form/src/com/fr/design/form/layout/FRHorizontalLayout.java

@ -3,9 +3,20 @@
*/
package com.fr.design.form.layout;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WHorizontalBoxLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ContainerEvent;
/**
* @author richer
@ -70,4 +81,29 @@ public class FRHorizontalLayout extends FRFlowLayout {
}
return total;
}
public void componentAdded(ContainerEvent e, WHorizontalBoxLayout wlayout){
XWidgetCreator creator = (XWidgetCreator) e.getChild();
Widget wgt = creator.toData();
wlayout.setWidthAtWidget(wgt, creator.getWidth());
}
public Dimension calculatePreferredSize(WHorizontalBoxLayout wlayout, Widget widget){
return new Dimension(wlayout.getWidthAtWidget(widget), 0);
}
public void setDirections(Component component){
XCreator creator = (XCreator) component;
creator.setDirections(new int[]{Direction.LEFT, Direction.RIGHT});
}
public LayoutAdapter getLayoutAdapter(XWHorizontalBoxLayout xwHorizontalBoxLayout){
return new FRHorizontalLayoutAdapter(xwHorizontalBoxLayout);
}
public void adjustComponents(Component component){
}
}

34
designer_form/src/com/fr/design/form/layout/FRVerticalLayout.java

@ -3,9 +3,20 @@
*/
package com.fr.design.form.layout;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WHorizontalBoxLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ContainerEvent;
/**
@ -73,4 +84,27 @@ public class FRVerticalLayout extends FRFlowLayout {
}
return total;
}
public void componentAdded(ContainerEvent e, WHorizontalBoxLayout wlayout){
XWidgetCreator creator = (XWidgetCreator) e.getChild();
Widget wgt = creator.toData();
wlayout.setWidthAtWidget(wgt, creator.getHeight());
}
public Dimension calculatePreferredSize(WHorizontalBoxLayout wlayout, Widget widget){
return new Dimension(0, wlayout.getWidthAtWidget(widget));
}
public void setDirections(Component component){
XCreator creator = (XCreator) component;
creator.setDirections(new int[]{Direction.TOP, Direction.BOTTOM});
}
public LayoutAdapter getLayoutAdapter(XWHorizontalBoxLayout xwHorizontalBoxLayout){
return new FRVerticalLayoutAdapter(xwHorizontalBoxLayout);
}
}

5
designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java

@ -22,6 +22,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
@ -322,9 +323,9 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
*
* @return 同上
*/
public Action[] getActions() {
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
}
return designerActions;

77
designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java

@ -4,19 +4,11 @@
package com.fr.design.gui.xpane;
import java.awt.BorderLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.Utils;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
@ -25,14 +17,9 @@ import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import com.fr.stable.Constants;
/**
* CardTagLayoutBorderPane Pane.
@ -42,6 +29,7 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
initComponents();
}
protected UIScrollPane initRightBottomPane(){
this.setFontSizeComboBox(new UIComboBox(FRFontPane.FONT_SIZES));
this.setFontNameComboBox(new UIComboBox(Utils.getAvailableFontFamilyNames4Report()));
@ -90,66 +78,35 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
JPanel rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
defaultPane.add(rightPane, BorderLayout.EAST);
rightPane.add(initRightBottomPane(), BorderLayout.CENTER);
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (!jTemplate.isJWorkBook() && ((JForm)jTemplate).isSelectRootPane()){
//界面上表单主体只有背景和透明度可以设置
rightPane.add(initBodyRightTopPane(), BorderLayout.NORTH);
} else {
rightPane.add(initRightTopPane(), BorderLayout.NORTH);
}
rightPane.add(initRightTopPane(), BorderLayout.NORTH);
}
protected JComponent[] getBorderTypeComp(){
return new JComponent[]{null, null};
}
protected JComponent[] getBorderCornerSpinnerComp(){
return new JComponent[]{null, null};
}
protected void switchBorderType(){
return;
}
public LayoutBorderStyle update() {
LayoutBorderStyle style = new LayoutBorderStyle();
style.setType(this.getBorderTypeCombo().getSelectedIndex());
style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex());
style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle());
style.setColor(this.getCurrentLineColorPane().getColor());
style.setBackground(this.getBackgroundPane().update());
style.setAlpha((float)(this.getNumberDragPane().updateBean()/this.getMaxNumber()));
WidgetTitle title = style.getTitle() == null ? new WidgetTitle() : style.getTitle();
title.setTextObject("title");
FRFont frFont = title.getFrFont();
frFont = frFont.applySize((Integer)this.getFontSizeComboBox().getSelectedItem());
frFont = frFont.applyName(this.getFontNameComboBox().getSelectedItem().toString());
frFont = frFont.applyForeground(this.getColorSelectPane().getColor());
frFont = updateItalicBold(frFont);
int line = this.getUnderline().isSelected() ? this.getUnderlineCombo().getSelectedLineStyle() : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
title.setFrFont(frFont);
title.setBackground(this.getTitleBackgroundPane().update());
style.setTitle(title);
return style;
}
protected void populateBorderType(){
return;
}
protected void populateTitle(){
WidgetTitle widgetTitle = this.getBorderStyle() == null ? new WidgetTitle() : this.getBorderStyle().getTitle();
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle;
populateFont(widgetTitle);
this.getUnderline().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
paintPreviewPane();
}
});
this.getUnderlineCombo().addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
paintPreviewPane();
}
});
this.getTitleBackgroundPane().populateBean(widgetTitle.getBackground());
this.getTitleBackgroundPane().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
paintPreviewPane();
}
});
paintPreviewPane();
protected void populateTitle(){
return;
}
}

611
designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java

@ -14,7 +14,11 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.*;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -37,15 +41,35 @@ import com.fr.general.FRFont;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicToggleButtonUI;
import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.RoundRectangle2D;
/**
@ -99,45 +123,45 @@ public class LayoutBorderPane extends BasicPane {
private int iconWidth = 32;
public LayoutBorderStyle getBorderStyle() {
return borderStyle;
}
return borderStyle;
}
public void setBorderStyle(LayoutBorderStyle borderStyle) {
this.borderStyle = borderStyle;
}
public void setBorderStyle(LayoutBorderStyle borderStyle) {
this.borderStyle = borderStyle;
}
public LayoutBorderPreviewPane getLayoutBorderPreviewPane() {
return layoutBorderPreviewPane;
}
public LayoutBorderPreviewPane getLayoutBorderPreviewPane() {
return layoutBorderPreviewPane;
}
public void setLayoutBorderPreviewPane(
LayoutBorderPreviewPane layoutBorderPreviewPane) {
this.layoutBorderPreviewPane = layoutBorderPreviewPane;
}
public void setLayoutBorderPreviewPane(
LayoutBorderPreviewPane layoutBorderPreviewPane) {
this.layoutBorderPreviewPane = layoutBorderPreviewPane;
}
public UIComboBox getBorderTypeCombo() {
return borderTypeCombo;
}
public UIComboBox getBorderTypeCombo() {
return borderTypeCombo;
}
public void setBorderTypeCombo(UIComboBox borderTypeCombo) {
this.borderTypeCombo = borderTypeCombo;
}
public void setBorderTypeCombo(UIComboBox borderTypeCombo) {
this.borderTypeCombo = borderTypeCombo;
}
public UIComboBox getBorderStyleCombo() {
return borderStyleCombo;
}
public UIComboBox getBorderStyleCombo() {
return borderStyleCombo;
}
public void setBorderStyleCombo(UIComboBox borderStyleCombo) {
this.borderStyleCombo = borderStyleCombo;
}
public void setBorderStyleCombo(UIComboBox borderStyleCombo) {
this.borderStyleCombo = borderStyleCombo;
}
public LineComboBox getCurrentLineCombo() {
return currentLineCombo;
}
public LineComboBox getCurrentLineCombo() {
return currentLineCombo;
}
public void setCurrentLineCombo(LineComboBox currentLineCombo) {
this.currentLineCombo = currentLineCombo;
}
public void setCurrentLineCombo(LineComboBox currentLineCombo) {
this.currentLineCombo = currentLineCombo;
}
public UISpinner getBorderCornerSpinner() {
@ -150,148 +174,148 @@ public class LayoutBorderPane extends BasicPane {
public UIColorButton getCurrentLineColorPane() {
return currentLineColorPane;
}
return currentLineColorPane;
}
public void setCurrentLineColorPane(UIColorButton currentLineColorPane) {
this.currentLineColorPane = currentLineColorPane;
}
public void setCurrentLineColorPane(UIColorButton currentLineColorPane) {
this.currentLineColorPane = currentLineColorPane;
}
public BackgroundSpecialPane getBackgroundPane() {
return backgroundPane;
}
public BackgroundSpecialPane getBackgroundPane() {
return backgroundPane;
}
public void setBackgroundPane(BackgroundSpecialPane backgroundPane) {
this.backgroundPane = backgroundPane;
}
public void setBackgroundPane(BackgroundSpecialPane backgroundPane) {
this.backgroundPane = backgroundPane;
}
public UINumberDragPane getNumberDragPane() {
return numberDragPane;
}
public UINumberDragPane getNumberDragPane() {
return numberDragPane;
}
public void setNumberDragPane(UINumberDragPane numberDragPane) {
this.numberDragPane = numberDragPane;
}
public void setNumberDragPane(UINumberDragPane numberDragPane) {
this.numberDragPane = numberDragPane;
}
public TinyFormulaPane getFormulaPane() {
return formulaPane;
}
public TinyFormulaPane getFormulaPane() {
return formulaPane;
}
public void setFormulaPane(TinyFormulaPane formulaPane) {
this.formulaPane = formulaPane;
}
public void setFormulaPane(TinyFormulaPane formulaPane) {
this.formulaPane = formulaPane;
}
public UIComboBox getFontNameComboBox() {
return fontNameComboBox;
}
public UIComboBox getFontNameComboBox() {
return fontNameComboBox;
}
public void setFontNameComboBox(UIComboBox fontNameComboBox) {
this.fontNameComboBox = fontNameComboBox;
}
public void setFontNameComboBox(UIComboBox fontNameComboBox) {
this.fontNameComboBox = fontNameComboBox;
}
public UIComboBox getFontSizeComboBox() {
return fontSizeComboBox;
}
public UIComboBox getFontSizeComboBox() {
return fontSizeComboBox;
}
public void setFontSizeComboBox(UIComboBox fontSizeComboBox) {
this.fontSizeComboBox = fontSizeComboBox;
}
public void setFontSizeComboBox(UIComboBox fontSizeComboBox) {
this.fontSizeComboBox = fontSizeComboBox;
}
public UIColorButton getColorSelectPane() {
return colorSelectPane;
}
public UIColorButton getColorSelectPane() {
return colorSelectPane;
}
public void setColorSelectPane(UIColorButton colorSelectPane) {
this.colorSelectPane = colorSelectPane;
}
public void setColorSelectPane(UIColorButton colorSelectPane) {
this.colorSelectPane = colorSelectPane;
}
public UIToggleButton getBold() {
return bold;
}
public UIToggleButton getBold() {
return bold;
}
public void setBold(UIToggleButton bold) {
this.bold = bold;
}
public void setBold(UIToggleButton bold) {
this.bold = bold;
}
public UIToggleButton getItalic() {
return italic;
}
public UIToggleButton getItalic() {
return italic;
}
public void setItalic(UIToggleButton italic) {
this.italic = italic;
}
public void setItalic(UIToggleButton italic) {
this.italic = italic;
}
public UIToggleButton getUnderline() {
return underline;
}
public UIToggleButton getUnderline() {
return underline;
}
public void setUnderline(UIToggleButton underline) {
this.underline = underline;
}
public void setUnderline(UIToggleButton underline) {
this.underline = underline;
}
public LineComboBox getUnderlineCombo() {
return underlineCombo;
}
public LineComboBox getUnderlineCombo() {
return underlineCombo;
}
public void setUnderlineCombo(LineComboBox underlineCombo) {
this.underlineCombo = underlineCombo;
}
public void setUnderlineCombo(LineComboBox underlineCombo) {
this.underlineCombo = underlineCombo;
}
public UIButtonGroup gethAlignmentPane() {
return hAlignmentPane;
}
public UIButtonGroup gethAlignmentPane() {
return hAlignmentPane;
}
public void sethAlignmentPane(UIButtonGroup hAlignmentPane) {
this.hAlignmentPane = hAlignmentPane;
}
public void sethAlignmentPane(UIButtonGroup hAlignmentPane) {
this.hAlignmentPane = hAlignmentPane;
}
public BackgroundNoImagePane getTitleBackgroundPane() {
return titleBackgroundPane;
}
public BackgroundNoImagePane getTitleBackgroundPane() {
return titleBackgroundPane;
}
public void setTitleBackgroundPane(BackgroundNoImagePane titleBackgroundPane) {
this.titleBackgroundPane = titleBackgroundPane;
}
public void setTitleBackgroundPane(BackgroundNoImagePane titleBackgroundPane) {
this.titleBackgroundPane = titleBackgroundPane;
}
public UIScrollPane getTitlePane() {
return titlePane;
}
public UIScrollPane getTitlePane() {
return titlePane;
}
public void setTitlePane(UIScrollPane titlePane) {
this.titlePane = titlePane;
}
public void setTitlePane(UIScrollPane titlePane) {
this.titlePane = titlePane;
}
public int getMinNumber() {
return minNumber;
}
public int getMinNumber() {
return minNumber;
}
public void setMinNumber(int minNumber) {
this.minNumber = minNumber;
}
public void setMinNumber(int minNumber) {
this.minNumber = minNumber;
}
public double getMaxNumber() {
return maxNumber;
}
public double getMaxNumber() {
return maxNumber;
}
public void setMaxNumber(double maxNumber) {
this.maxNumber = maxNumber;
}
public void setMaxNumber(double maxNumber) {
this.maxNumber = maxNumber;
}
public int getIconWidth() {
return iconWidth;
}
public int getIconWidth() {
return iconWidth;
}
public void setIconWidth(int iconWidth) {
this.iconWidth = iconWidth;
}
public void setIconWidth(int iconWidth) {
this.iconWidth = iconWidth;
}
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
};
public final static String[] BORDER_TYPE = new String[]{Inter.getLocText("FR-Designer-Widget-Style_Standard"), Inter.getLocText("FR-Designer-Widget-Style_Custom")};
public final static String[] BORDER_STYLE= new String[]{Inter.getLocText("FR-Designer-Widget-Style_Common"), Inter.getLocText("FR-Designer-Widget-Style_Shadow")};
@ -303,7 +327,7 @@ public class LayoutBorderPane extends BasicPane {
}
protected void initComponents() {
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -336,17 +360,7 @@ public class LayoutBorderPane extends BasicPane {
}
protected UIScrollPane initRightTopPane(){
this.borderTypeCombo = new UIComboBox(BORDER_TYPE);
this.borderTypeCombo.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(borderTypeCombo.getSelectedIndex() == 0){
titlePane.setVisible(false);
} else {
titlePane.setVisible(true);
currentLineCombo.setSelectedItem(Constants.LINE_THIN);
}
}
});
switchBorderType();
this.borderStyleCombo = new UIComboBox(BORDER_STYLE);
this.currentLineCombo = new LineComboBox(BORDER_LINE_STYLE_ARRAY);
this.currentLineColorPane = new UIColorButton(null);
@ -366,15 +380,15 @@ public class LayoutBorderPane extends BasicPane {
double[] rowSize = {p,p,p,p,p,p,p,p};
double[] columnSize = { p, MAX_WIDTH};
JPanel rightTopContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Frame_Style")), borderTypeCombo},
getBorderTypeComp(),
{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Render_Style")), borderStyleCombo},
{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Border_Line")), currentLineCombo},
{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Border_Color")), buttonPane},
{new UILabel(Inter.getLocText("plugin-ChartF_Radius")+":"),borderCornerSpinner},
getBorderCornerSpinnerComp(),
{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Body_Background")), backgroundPane},
{new UILabel(""),new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Alpha"))},
{new UILabel(""),transparencyPane},
}, rowSize, columnSize, 10);
}, rowSize, columnSize, 10);
rightTopContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12));
UIScrollPane rightTopPane = new UIScrollPane(rightTopContentPane);
rightTopPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer-Widget-Style_Frame"),null));
@ -382,6 +396,27 @@ public class LayoutBorderPane extends BasicPane {
return rightTopPane;
}
protected JComponent[] getBorderTypeComp(){
return new JComponent[]{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Frame_Style")), borderTypeCombo};
}
protected JComponent[] getBorderCornerSpinnerComp(){
return new JComponent[]{new UILabel(Inter.getLocText("plugin-ChartF_Radius")+":"),borderCornerSpinner};
}
protected void switchBorderType(){
this.borderTypeCombo = new UIComboBox(BORDER_TYPE);
this.borderTypeCombo.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(borderTypeCombo.getSelectedIndex() == 0){
titlePane.setVisible(false);
} else {
titlePane.setVisible(true);
currentLineCombo.setSelectedItem(Constants.LINE_THIN);
}
}
});
}
@ -524,8 +559,8 @@ public class LayoutBorderPane extends BasicPane {
title.setPosition((Integer)hAlignmentPane.getSelectedItem());
title.setBackground(titleBackgroundPane.update());
style.setTitle(title);
return style;
}
return style;
}
protected FRFont updateItalicBold(FRFont frFont) {
int italic_bold = frFont.getStyle();
@ -547,10 +582,10 @@ public class LayoutBorderPane extends BasicPane {
}
public void populate(LayoutBorderStyle style) {
if(this.borderStyle == null) {
borderStyle = new LayoutBorderStyle();
}
this.borderStyle.setStyle(style);
if(this.borderStyle == null) {
borderStyle = new LayoutBorderStyle();
}
this.borderStyle.setStyle(style);
populateBorder();
@ -558,7 +593,7 @@ public class LayoutBorderPane extends BasicPane {
}
protected void populateBorder(){
protected void populateBorderType(){
this.borderTypeCombo.setSelectedIndex(borderStyle.getType());
this.borderTypeCombo.addItemListener(new ItemListener() {
@Override
@ -566,6 +601,10 @@ public class LayoutBorderPane extends BasicPane {
paintPreviewPane();
}
});
}
protected void populateBorder(){
populateBorderType();
this.borderStyleCombo.setSelectedIndex(borderStyle.getBorderStyle());
this.borderStyleCombo.addItemListener(new ItemListener() {
@Override
@ -634,7 +673,7 @@ public class LayoutBorderPane extends BasicPane {
titleBackgroundPane.populateBean(widgetTitle.getBackground());
titleBackgroundPane.populateBean(widgetTitle.getBackground());
this.titleBackgroundPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@ -717,26 +756,26 @@ public class LayoutBorderPane extends BasicPane {
}
private void populateFourmula(WidgetTitle widgetTitle) {
this.formulaPane.populateBean(widgetTitle.getTextObject().toString());
this.formulaPane.getUITextField().getDocument()
.addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
paintPreviewPane();
}
@Override
public void removeUpdate(DocumentEvent e) {
paintPreviewPane();
}
@Override
public void changedUpdate(DocumentEvent e) {
paintPreviewPane();
}
});
}
private void populateFourmula(WidgetTitle widgetTitle) {
this.formulaPane.populateBean(widgetTitle.getTextObject().toString());
this.formulaPane.getUITextField().getDocument()
.addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
paintPreviewPane();
}
@Override
public void removeUpdate(DocumentEvent e) {
paintPreviewPane();
}
@Override
public void changedUpdate(DocumentEvent e) {
paintPreviewPane();
}
});
}
protected JPanel createVerButtonPane(JToggleButton noBorder, String text) {
@ -750,116 +789,116 @@ public class LayoutBorderPane extends BasicPane {
protected class VerButtonPane extends JPanel {
JToggleButton noBorder;
BorderButton normalBorder;
BorderButton RoundedBorder;
ButtonGroup group;
private VerButtonPane () {
setLayout(new FlowLayout(FlowLayout.CENTER));
setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
group = new ButtonGroup();
noBorder = new BorderButton(NO_BORDERS);
normalBorder = new BorderButton(RIGHTANGLE_BORDERS);
RoundedBorder = new BorderButton(ROUNDED_BORDERS);
group.add(noBorder);
group.add(normalBorder);
group.add(RoundedBorder);
JToggleButton noBorder;
BorderButton normalBorder;
BorderButton RoundedBorder;
ButtonGroup group;
private VerButtonPane () {
setLayout(new FlowLayout(FlowLayout.CENTER));
setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
group = new ButtonGroup();
noBorder = new BorderButton(NO_BORDERS);
normalBorder = new BorderButton(RIGHTANGLE_BORDERS);
RoundedBorder = new BorderButton(ROUNDED_BORDERS);
group.add(noBorder);
group.add(normalBorder);
group.add(RoundedBorder);
// add(createVerButtonPane(noBorder, Inter.getLocText("None")));
// add(createVerButtonPane(normalBorder, Inter.getLocText("Border-Style-Normal")));
// add(createVerButtonPane(RoundedBorder, Inter.getLocText("Border-Style-Radius")));
}
}
public void populate(LayoutBorderStyle style) {
if(style.getBorder() == Constants.LINE_NONE) {
group.setSelected(noBorder.getModel(), true);
} else if(style.getBorderRadius() != NO_RADIUS) {
public void populate(LayoutBorderStyle style) {
if(style.getBorder() == Constants.LINE_NONE) {
group.setSelected(noBorder.getModel(), true);
} else if(style.getBorderRadius() != NO_RADIUS) {
group.setSelected(RoundedBorder.getModel(), true);
} else {
group.setSelected(normalBorder.getModel(), true);
}
}
}
private class BorderButton extends JToggleButton {
private BorderButton(int border) {
super();
this.setIcon(new BorderButtonIcon(border));
addBorderActionListener(border);
setPreferredSize(new Dimension(32, 32));
this.setBorder(new UIRoundedBorder(new Color(220, 220, 220), 1, 5));
this.setRolloverEnabled(true);
}
@Override
public Border getBorder() {
ButtonModel model = getModel();
if (this.isSelected()) {
return null;
}
if (isRolloverEnabled() && model.isRollover()) {
return new UIRoundedBorder(new Color(148, 148, 148), 1, 5);
}
return super.getBorder();
}
@Override
public void updateUI() {
setUI(new BorderToggleButtonUI());
}
private void addBorderActionListener(final int border) {
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (border == 0) {
borderStyle.reset();
} else {
borderStyle.setColor(currentLineColorPane.getColor());
borderStyle.setBorder(currentLineCombo.getSelectedLineStyle());
borderStyle.setBorderRadius((int)borderCornerSpinner.getValue());
}
group.setSelected(normalBorder.getModel(), true);
}
}
}
private class BorderButton extends JToggleButton {
private BorderButton(int border) {
super();
this.setIcon(new BorderButtonIcon(border));
addBorderActionListener(border);
setPreferredSize(new Dimension(32, 32));
this.setBorder(new UIRoundedBorder(new Color(220, 220, 220), 1, 5));
this.setRolloverEnabled(true);
}
@Override
public Border getBorder() {
ButtonModel model = getModel();
if (this.isSelected()) {
return null;
}
if (isRolloverEnabled() && model.isRollover()) {
return new UIRoundedBorder(new Color(148, 148, 148), 1, 5);
}
return super.getBorder();
}
@Override
public void updateUI() {
setUI(new BorderToggleButtonUI());
}
private void addBorderActionListener(final int border) {
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (border == 0) {
borderStyle.reset();
} else {
borderStyle.setColor(currentLineColorPane.getColor());
borderStyle.setBorder(currentLineCombo.getSelectedLineStyle());
borderStyle.setBorderRadius((int)borderCornerSpinner.getValue());
}
layoutBorderPreviewPane.repaint();
}
});
}
}
private class BorderToggleButtonUI extends BasicToggleButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
paintBackground(g, (AbstractButton) c);
super.paint(g, c);
}
private void paintBackground(Graphics g, AbstractButton b) {
if (b.isContentAreaFilled()) {
Dimension size = b.getSize();
Background background = new GradientBackground(new Color(247, 247, 247), new Color(228, 228, 228),
GradientBackground.TOP2BOTTOM);
background.paint(g, new RoundRectangle2D.Double(2, 2, size.width - 4, size.height - 4, 5, 5));
}
}
private void paintBorder(Graphics g, Color lineColor, int width, int height) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(lineColor);
g2d.drawRoundRect(0, 0, width - 1, height - 1, 5, 5);
g2d.setColor(Color.WHITE);
g2d.drawRoundRect(1, 1, width - 3, height - 3, 5, 5);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
@Override
protected void paintButtonPressed(Graphics g, AbstractButton b) {
Dimension size = b.getSize();
paintBorder(g, new Color(78,143,203), size.height, size.width);
}
}
}
});
}
}
private class BorderToggleButtonUI extends BasicToggleButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
paintBackground(g, (AbstractButton) c);
super.paint(g, c);
}
private void paintBackground(Graphics g, AbstractButton b) {
if (b.isContentAreaFilled()) {
Dimension size = b.getSize();
Background background = new GradientBackground(new Color(247, 247, 247), new Color(228, 228, 228),
GradientBackground.TOP2BOTTOM);
background.paint(g, new RoundRectangle2D.Double(2, 2, size.width - 4, size.height - 4, 5, 5));
}
}
private void paintBorder(Graphics g, Color lineColor, int width, int height) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(lineColor);
g2d.drawRoundRect(0, 0, width - 1, height - 1, 5, 5);
g2d.setColor(Color.WHITE);
g2d.drawRoundRect(1, 1, width - 3, height - 3, 5, 5);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
@Override
protected void paintButtonPressed(Graphics g, AbstractButton b) {
Dimension size = b.getSize();
paintBorder(g, new Color(78,143,203), size.height, size.width);
}
}
// Icon to display in shortcut setting buttons
private class BorderButtonIcon implements Icon {
@ -883,13 +922,13 @@ public class LayoutBorderPane extends BasicPane {
g.drawRect(3, 3, this.getIconWidth() - 7, this.getIconHeight() - 7);
} else if (display == LayoutBorderPane.ROUNDED_BORDERS) {
g.setColor(Color.black);
g.drawRoundRect(3, 3, this.getIconWidth() - 7, this.getIconHeight() - 7, 6, 6);
g.drawRoundRect(3, 3, this.getIconWidth() - 7, this.getIconHeight() - 7, 6, 6);
}
}
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Widget_Style");
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Widget_Style");
}
}

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

@ -1,27 +1,39 @@
package com.fr.design.mainframe;
import java.awt.Component;
import java.util.ArrayList;
import javax.swing.DropMode;
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.creator.*;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
public class ComponentTree extends JTree {
private FormDesigner designer;
private ComponentTreeModel model;
private UITreeUI uiTreeUI = new UITreeUI();
private PopupPreviewPane previewPane;
private static final int PADDING_LEFT = 5;
private static final int PADDING_TOP = 5;
public ComponentTree(FormDesigner designer) {
this.designer = designer;
this.setBackground(UIConstants.NORMAL_BACKGROUND);
this.setBackground(UIConstants.TREE_BACKGROUND);
setRootVisible(true);
setCellRenderer(new ComponentTreeCellRenderer());
getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
@ -29,8 +41,17 @@ public class ComponentTree extends JTree {
this.setDropMode(DropMode.ON_OR_INSERT);
this.setTransferHandler(new TreeTransferHandler());
this.refreshTreeRoot();
addTreeSelectionListener(designer);
initListeners();
setEditable(true);
setUI(uiTreeUI);
setBorder(BorderFactory.createEmptyBorder(PADDING_TOP, PADDING_LEFT, 0, 0));
}
private void initListeners() {
this.addTreeSelectionListener(designer);
ComponetTreeMouseListener componetTreeMouseListener = new ComponetTreeMouseListener(this);
this.addMouseMotionListener(componetTreeMouseListener);
this.addMouseListener(componetTreeMouseListener);
}
public FormDesigner getDesigner() {
@ -41,39 +62,49 @@ public class ComponentTree extends JTree {
* 构造函数
*
* @param designer 设计界面组件
* @param model 构造JTree的model
* @param model 构造JTree的model
*/
public ComponentTree(FormDesigner designer,ComponentTreeModel model) {
public ComponentTree(FormDesigner designer, ComponentTreeModel model) {
this(designer);
this.setModel(model);
}
public void setSelectionPath(TreePath path) {
// 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块)
designer.stopEditing(path);
super.setSelectionPath(path);
}
@Override
public void removeAll() {
if (previewPane != null) {
previewPane.setVisible(false);
previewPane.removeAll();
}
super.removeAll();
}
/**
* 是否可编辑
*
* @param path 树路径
* @return 是则返回true
*/
@Override
public boolean isPathEditable(TreePath path) {
Object object = path.getLastPathComponent();
if (object == designer.getRootComponent()) {
return false;
}
return super.isPathEditable(path);
return false;
}
/**
* 将值转换为文本
* @param value
*
* @param value
* @param selected 是否选中
* @param expanded 扩展
* @param leaf 是否叶子
* @param row
* @param leaf 是否叶子
* @param row
* @param hasFocus 是否焦点
*
* @return 返回文本
*/
@Override
@ -96,12 +127,10 @@ public class ComponentTree extends JTree {
*/
public void refreshUI() {
updateUI();
setUI(uiTreeUI);
}
public TreePath[] getSelectedTreePath() {
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators();
TreePath[] paths = new TreePath[creators.length];
@ -112,10 +141,8 @@ public class ComponentTree extends JTree {
}
/**
*搜索指定名称的路径
* 搜索指定名称的路径
*
* @param text 名称
* @return 树路径
@ -132,7 +159,7 @@ public class ComponentTree extends JTree {
for (int i = 0; i < paths.length; i++) {
paths[i] = buildTreePath(searchList.get(i));
}
if(paths.length > 0) {
if (paths.length > 0) {
setAndScrollSelectionPath(paths);
} else {
setSelectionPath();
@ -141,7 +168,7 @@ public class ComponentTree extends JTree {
}
private void setSelectionPath(){
private void setSelectionPath() {
/**
* 不让传null参数所以只有自己定义
@ -192,13 +219,13 @@ public class ComponentTree extends JTree {
while (parent != null) {
XCreator creator = (XCreator) parent;
path.add(0, parent);
if (creator != comp ) {
if (creator != comp) {
creator.notShowInComponentTree(path);
}
//绝对布局作为body的时候不显示自适应布局父层
if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) {
if ((parent.getParent() != null)
&& ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){
&& ((XCreator) parent.getParent()).acceptType(XWFitLayout.class)) {
parent = parent.getParent().getParent();
continue;
}
@ -210,4 +237,123 @@ public class ComponentTree extends JTree {
return new TreePath(components);
}
private void popupPreviewPane(int popupPosYOnScreen, XCreator comp) {
if (previewPane == null) {
previewPane = new PopupPreviewPane();
}
if (previewPane.isVisible() && previewPane.getLocationOnScreen().y != popupPosYOnScreen) {
previewPane.setVisible(false);
}
if (!previewPane.isVisible()) {
previewPane.setComp(comp);
int popupPosY = popupPosYOnScreen - FormHierarchyTreePane.getInstance().getLocationOnScreen().y;
GUICoreUtils.showPopupMenu(previewPane, FormHierarchyTreePane.getInstance(), -previewPane.getPreferredSize().width, popupPosY);
}
}
private void hidePreviewPane() {
if (previewPane != null && previewPane.isVisible()) {
previewPane.setVisible(false);
}
}
private final class ComponetTreeMouseListener extends MouseAdapter {
private final JTree tree;
private ComponetTreeMouseListener(JTree tree) {
this.tree = tree;
}
@Override
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int selRow = tree.getRowForLocation(p.x, p.y);
TreeCellRenderer r = tree.getCellRenderer();
if (selRow != -1 && r != null) {
TreePath path = tree.getPathForRow(selRow);
Point point = tree.getPathBounds(path).getLocation();
SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent();
popupPreviewPane(point.y, comp);
} else {
hidePreviewPane();
}
}
@Override
public void mouseExited(MouseEvent e) {
hidePreviewPane();
}
}
private class PopupPreviewPane extends JPopupMenu {
private Container contentPane;
private BufferedImage compImage;
private static final int MAX_WIDTH = 360;
private static final int MAX_HEIGHT = 280;
PopupPreviewPane() {
contentPane = new JPanel();
contentPane.setBackground(Color.white);
this.setLayout(new BorderLayout());
this.add(contentPane, BorderLayout.CENTER);
this.setOpaque(false);
setPreferredSize(new Dimension(MAX_WIDTH, MAX_HEIGHT));
setBorder(BorderFactory.createLineBorder(UIConstants.LINE_COLOR));
}
public void setComp(XCreator comp) {
try {
this.compImage = componentToImage(comp);
this.updateSize();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (compImage != null) {
g.drawImage(compImage, 0, 0, getWidth(), getHeight(), null);
}
}
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
}
public void menuSelectionChanged(boolean isIncluded) {
}
public Container getContentPane() {
return contentPane;
}
private BufferedImage componentToImage(Component comp) throws IOException
{
BufferedImage im = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_ARGB);
comp.paint(im.getGraphics());
return im;
}
// 根据控件内容,更新弹出框大小
private void updateSize() {
int width = compImage.getWidth();
int height = compImage.getHeight();
double aspectRatio = (double)width / height;
if (width > MAX_WIDTH) {
width = MAX_WIDTH;
height = (int)(width / aspectRatio);
}
if (height > MAX_HEIGHT) {
height = MAX_HEIGHT;
width = (int)(height * aspectRatio);
}
this.setPreferredSize(new Dimension(width, height));
}
}
}

23
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -11,11 +11,13 @@ import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XCardSwitchButton;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.Inter;
import com.fr.stable.Constants;
@ -489,7 +491,16 @@ public class EditingMouseListener extends MouseInputAdapter {
return false;
}
private XCreator processTopLayoutMouseClick(XCreator creator) {
// 点击控件树,会触发此方法。如果在设计器中选中组件,则直接走 processTopLayoutMouseClick
public void stopEditTopLayout(XCreator creator) {
boolean isTabpaneSelected = creator instanceof XWCardLayout && creator.getParent().equals(clickTopLayout);
if (clickTopLayout != null && (isTabpaneSelected || clickTopLayout.equals(creator))) {
clickTopLayout.setEditable(false);
}
processTopLayoutMouseClick(creator);
}
public XCreator processTopLayoutMouseClick(XCreator creator) {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if (topLayout != null) {
if (clickTopLayout != null && !clickTopLayout.equals(topLayout) && !isCreatorInLayout(clickTopLayout,
@ -518,8 +529,9 @@ public class EditingMouseListener extends MouseInputAdapter {
*/
public void mouseClicked(MouseEvent e) {
XCreator creator = designer.getComponentAt(e);
boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3;
if (e.getButton() != MouseEvent.BUTTON1 && !creator.acceptType(XCardSwitchButton.class)) {
if (!isValidButton && !creator.acceptType(XCardSwitchButton.class)) {
return;
}
@ -527,6 +539,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (creator != null) {
creator.respondClick(this, e);
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu cellPopupMenu = creator.createPopupMenu(designer);
if (cellPopupMenu != null) {
GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY());
}
}
}
creator.doLayout();
LayoutUtils.layoutRootContainer(designer.getRootComponent());
@ -589,6 +607,7 @@ public class EditingMouseListener extends MouseInputAdapter {
}
designer.invalidate();
designer.repaint();
currentXCreator.stopEditing();
currentXCreator = null;
currentEditor = null;
return true;

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

@ -4,13 +4,11 @@ import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.Painter;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
import com.fr.design.designer.beans.actions.PasteAction;
import com.fr.design.designer.beans.actions.*;
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter;
import com.fr.design.designer.beans.events.CreatorEventListenerTable;
import com.fr.design.designer.beans.events.DesignerEditListener;
@ -108,7 +106,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private int resolution = ScreenResolution.getScreenResolution();
// 编辑状态的事件表
private CreatorEventListenerTable edit;
protected Action[] designerActions;
protected UpdateAction[] designerActions;
private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer;
@ -216,7 +214,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
}
}
/**
* 是否有查询按钮
*
@ -672,6 +669,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
setParameterArray(getNoRepeatParas(getTarget().getParameters()));
refreshParameter();
}
} else {
for( UpdateAction action : getActions()) {
action.update();
}
}
}
@ -1126,14 +1127,35 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*
* @return 同上
*/
public Action[] getActions() {
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this),
new MoveUpAction(this), new MoveDownAction(this)};
}
return designerActions;
}
// 当前选中控件可以上移一层吗?
public boolean isCurrentComponentMovableUp() {
XCreator creator = getSelectionModel().getSelection().getSelectedCreator();
Container container = creator.getParent();
if (container == null) {
return false;
}
return creator.isMovable() && container.getComponentZOrder(creator) > 0;
}
// 当前选中控件可以下移一层吗?
public boolean isCurrentComponentMovableDown() {
XCreator creator = getSelectionModel().getSelection().getSelectedCreator();
Container container = creator.getParent();
if (container == null) {
return false;
}
return creator.isMovable() && container.getComponentZOrder(creator) < container.getComponentCount() - 1;
}
protected Border getOuterBorder() {
return XCreatorConstants.AREA_BORDER;
}
@ -1238,6 +1260,16 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// do nothing
}
public void stopEditing(TreePath path) {
// do nothing
XCreator comp = (XCreator) path.getLastPathComponent();
editingMouseListener.stopEditing();
editingMouseListener.stopEditTopLayout(comp);
editingMouseListener.getSelectionModel().reset();
editingMouseListener.getSelectionModel().selectACreator(comp);
}
/**
* 返回表单控件权限编辑pane
*

44
designer_form/src/com/fr/design/mainframe/FormDesignerUI.java

@ -219,7 +219,7 @@ public class FormDesignerUI extends ComponentUI {
if (subCreator instanceof XLayoutContainer) {
paintAuthorityDetails(g, subCreator);
} else {
if (subCreator.toData().isDirtyWidget(selectedRoles)) {
if (subCreator.toData().isDirtyWidget(selectedRoles)) {
Rectangle creatorBounds = ComponentUtils.getRelativeBounds(subCreator);
creatorBounds.x -= designer.getArea().getHorizontalValue();
creatorBounds.y -= designer.getArea().getVerticalValue();
@ -273,9 +273,9 @@ public class FormDesignerUI extends ComponentUI {
creatorBounds.x -= designer.getArea().getHorizontalValue();
creatorBounds.y -= designer.getArea().getVerticalValue();
if (creator.acceptType(XWFitLayout.class)) {
resetFitlayoutBounds(creatorBounds);
resetFitlayoutBounds(creatorBounds);
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
resetCreatorBounds(creatorBounds);
resetCreatorBounds(creatorBounds);
}
GraphHelper.draw(g, creatorBounds, Constants.LINE_MEDIUM);
}
@ -286,28 +286,28 @@ public class FormDesignerUI extends ComponentUI {
* @param bound
*/
private void resetFitlayoutBounds( Rectangle bound) {
bound.x ++;
bound.width -= 2;
bound.y ++;
bound.height -= 2;
bound.x ++;
bound.width -= 2;
bound.y ++;
bound.height -= 2;
}
private void resetCreatorBounds( Rectangle bound) {
Rectangle rec = bound;
if (rec.x == 0) {
bound.x ++;
bound.width --;
}
if (rec.y == 0) {
bound.y ++;
bound.height --;
}
if (rec.x+rec.width == designer.getWidth()) {
bound.width --;
}
if (rec.y+rec.height == designer.getHeight()) {
bound.height --;
}
Rectangle rec = bound;
if (rec.x == 0) {
bound.x ++;
bound.width --;
}
if (rec.y == 0) {
bound.y ++;
bound.height --;
}
if (rec.x+rec.width == designer.getWidth()) {
bound.width --;
}
if (rec.y+rec.height == designer.getHeight()) {
bound.height --;
}
}

93
designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -1,35 +1,28 @@
package com.fr.design.mainframe;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UndoableAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.actions.ChangeNameAction;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UIListControlPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itoolbar.UIToolBarUI;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.mainframe.widget.UITreeComboBox;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.parameter.HierarchyTreePane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.base.BaseUtils;
import com.fr.general.Inter;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
/**
@ -37,14 +30,14 @@ import com.fr.design.layout.FRGUIPaneFactory;
*/
public class FormHierarchyTreePane extends FormDockView implements HierarchyTreePane {
public static final int NODE_LENGTH = 2;
public static final int PARA = 0;
public static final int BODY = 1;
private static final int NODE_LENGTH = 2;
private static final int PARA = 0;
private static final int BODY = 1;
private static final int SHORTS_SEPARATOR_POS = 4;
private static final int TOOLBAR_PADDING_RIGHT = 10;
private ShortCut4JControlPane[] shorts;
private ComponentTree componentTree;
private UITreeComboBox treeComboBox;
private ChangeNameAction changeVarNameAction;
public static FormHierarchyTreePane getInstance() {
return HOLDER.singleton;
@ -92,18 +85,21 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
public void refreshDockingView() {
FormDesigner formDesigner = this.getEditingFormDesigner();
removeAll();
changeVarNameAction = null;
if(this.componentTree != null) {
this.componentTree.removeAll();
}
if(this.treeComboBox != null) {
this.treeComboBox.removeAll();
}
if (formDesigner == null) {
clearDockingView();
return;
}
componentTree = new ComponentTree(formDesigner);
formDesigner.addDesignerEditListener(new DesignerEditListener() {
@Override
public void fireCreatorModified(DesignerEvent evt) {
componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath());
componentTree.refreshUI();
}
});
ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel();
XCreator root = (XCreator)treeModel.getRoot();
@ -120,25 +116,17 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
shorts = createShortcuts();
JPanel widgetPane = new JPanel();
widgetPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
widgetPane.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel headPane = new JPanel(new BorderLayout());
headPane.add(new UILabel(Inter.getLocText("FR-Designer-Selected_Widget") + " ",
SwingConstants.HORIZONTAL), BorderLayout.WEST);
headPane.add(getToolBarPane(), BorderLayout.EAST);
widgetPane.add(headPane, BorderLayout.CENTER);
treeComboBox = new UITreeComboBox(componentTree);
widgetPane.add(treeComboBox, BorderLayout.SOUTH);
widgetPane.add(getToolBarPane(), BorderLayout.CENTER);
UIScrollPane scrollPane = new UIScrollPane(componentTree);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setPreferredSize(new Dimension(210, 170));
widgetPane.add(scrollPane, BorderLayout.SOUTH);
return widgetPane;
}
private JPanel getToolBarPane() {
ToolBarDef toolbarDef = new ToolBarDef();
for (ShortCut4JControlPane sj : shorts) {
toolbarDef.addShortCut(sj.getShortCut());
}
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolBar.setUI(new UIToolBarUI(){
@Override
@ -148,19 +136,26 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
g2.fillRect(0, 0, c.getWidth(), c.getHeight());
}
});
toolbarDef.updateToolBar(toolBar);
for (int i = 0; i < shorts.length; i++) {
if (i == SHORTS_SEPARATOR_POS) {
toolBar.addSeparator(new Dimension(2, 16));
}
shorts[i].getShortCut().intoJToolBar(toolBar);
}
JPanel toolBarPane = new JPanel(new BorderLayout());
toolBarPane.add(toolBar, BorderLayout.CENTER);
return toolBarPane;
toolBarPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.BARNOMAL));
JPanel toolBarPaneWrapper = new JPanel(new BorderLayout());
toolBarPaneWrapper.add(toolBarPane, BorderLayout.CENTER);
toolBarPaneWrapper.setBorder(BorderFactory.createEmptyBorder(1, 0, 2, TOOLBAR_PADDING_RIGHT));
return toolBarPaneWrapper;
}
protected ShortCut4JControlPane[] createShortcuts() {
ArrayList<ShortCut4JControlPane> shortCutList = new ArrayList<>();
FormDesigner designer = getEditingFormDesigner();
if (changeVarNameAction == null) {
changeVarNameAction = new ChangeNameAction(designer);
}
shortCutList.add(new WidgetEnableShortCut(changeVarNameAction));
for (Action action : designer.getActions()) {
shortCutList.add(new WidgetEnableShortCut((UndoableAction)action));
}

12
designer_form/src/com/fr/design/mainframe/FormSelection.java

@ -8,7 +8,14 @@ import com.fr.base.FRContext;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.form.ui.Widget;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
@ -224,6 +231,9 @@ public class FormSelection {
int size = selection.size();
if (size == 1) {
XCreator creator = selection.get(0);
if(creator.acceptType(XWCardTagLayout.class)){
creator = (XCreator)selection.get(0).getParent();
}
creator.setBounds(rec);
if (creator.acceptType(XWParameterLayout.class)) {
designer.setParaHeight((int) rec.getHeight());

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

Loading…
Cancel
Save