Browse Source

Merge branch 'feature/10.0' of http://cloud.finedevelop.com:2015/scm/~kerry/design_10.0 into feature/10.0

master
kerry 6 years ago
parent
commit
88fab0d232
  1. 26
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 9
      designer-base/src/com/fr/design/actions/UpdateAction.java
  3. 24
      designer-base/src/com/fr/design/actions/file/PreferencePane.java
  4. 4
      designer-base/src/com/fr/design/actions/help/WebDemoAction.java
  5. 1
      designer-base/src/com/fr/design/constants/UIConstants.java
  6. 13
      designer-base/src/com/fr/design/event/DesignerOpenedListener.java
  7. 2
      designer-base/src/com/fr/design/file/HistoryTemplateListPane.java
  8. 3
      designer-base/src/com/fr/design/file/MutilTempalteTabPane.java
  9. 5
      designer-base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  10. 67
      designer-base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  11. 82
      designer-base/src/com/fr/design/gui/ibutton/UIRadioButton.java
  12. 4
      designer-base/src/com/fr/design/gui/icheckbox/UICheckBox.java
  13. 20
      designer-base/src/com/fr/design/gui/ispinner/UISpinner.java
  14. 4
      designer-base/src/com/fr/design/gui/style/FRFontPane.java
  15. 37
      designer-base/src/com/fr/design/icon/IconPathConstants.java
  16. BIN
      designer-base/src/com/fr/design/images/control/newEdit.png
  17. 15
      designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java
  18. 31
      designer-base/src/com/fr/design/layout/FRGUIPaneFactory.java
  19. 55
      designer-base/src/com/fr/design/layout/VerticalFlowLayout.java
  20. 38
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  21. 16
      designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java
  22. 27
      designer-base/src/com/fr/design/mainframe/JSliderPane.java
  23. 30
      designer-base/src/com/fr/design/mainframe/JTemplate.java
  24. 4
      designer-base/src/com/fr/design/mainframe/JVirtualTemplate.java
  25. 2
      designer-base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java
  26. 7
      designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  27. 9
      designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java
  28. 30
      designer-base/src/com/fr/design/mainframe/widget/BasicPropertyPane.java
  29. 14
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java
  30. 18
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java
  31. 40
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java
  32. 14
      designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  33. 5
      designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java
  34. 95
      designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java
  35. 74
      designer-base/src/com/fr/design/style/background/BackgroundFactory.java
  36. 88
      designer-base/src/com/fr/design/style/background/BackgroundTabPane.java
  37. 44
      designer-base/src/com/fr/design/utils/DesignUtils.java
  38. 47
      designer-base/src/com/fr/design/utils/gui/GUICoreUtils.java
  39. 24
      designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java
  40. 28
      designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java
  41. 28
      designer-base/src/com/fr/env/RemoteEnv.java
  42. 30
      designer-base/src/com/fr/env/SignIn.java
  43. 2
      designer-base/src/com/fr/start/BBSGuestPaneProvider.java
  44. 7
      designer-base/src/com/fr/start/BaseDesigner.java
  45. 154
      designer-base/src/com/fr/start/ServerStarter.java
  46. 34
      designer-base/src/com/fr/start/SplashStrategy.java
  47. 56
      designer-base/src/com/fr/start/TomcatFRHost.java
  48. 15
      designer-base/src/com/fr/start/server/EmbedServerEvent.java
  49. 133
      designer-base/src/com/fr/start/server/FRTomcat.java
  50. 134
      designer-base/src/com/fr/start/server/FineEmbedServer.java
  51. 62
      designer-base/src/com/fr/start/server/MultiOutputStream.java
  52. 76
      designer-base/src/com/fr/start/server/ServerManageFrame.java
  53. 198
      designer-base/src/com/fr/start/server/ServerTray.java
  54. 280
      designer-base/src/com/fr/start/server/TomcatHost.java
  55. 18
      designer-base/src/com/fr/start/server/TomcatServerListener.java
  56. 6
      designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java
  57. 3
      designer-form/src/com/fr/design/designer/beans/actions/CopyAction.java
  58. 3
      designer-form/src/com/fr/design/designer/beans/actions/CutAction.java
  59. 11
      designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java
  60. 17
      designer-form/src/com/fr/design/designer/beans/actions/FormWidgetEditAction.java
  61. 12
      designer-form/src/com/fr/design/designer/beans/actions/MoveDownAction.java
  62. 21
      designer-form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java
  63. 21
      designer-form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java
  64. 14
      designer-form/src/com/fr/design/designer/beans/actions/MoveUpAction.java
  65. 20
      designer-form/src/com/fr/design/designer/beans/actions/behavior/ComponentEnable.java
  66. 19
      designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableDownEnable.java
  67. 19
      designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableUpEnable.java
  68. 8
      designer-form/src/com/fr/design/designer/beans/actions/behavior/UpdateBehavior.java
  69. 16
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  70. 62
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java
  71. 9
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  72. 3
      designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java
  73. 3
      designer-form/src/com/fr/design/designer/beans/models/StateModel.java
  74. 14
      designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java
  75. 35
      designer-form/src/com/fr/design/designer/creator/XButton.java
  76. 35
      designer-form/src/com/fr/design/designer/creator/XChartEditor.java
  77. 240
      designer-form/src/com/fr/design/designer/creator/XCreator.java
  78. 26
      designer-form/src/com/fr/design/designer/creator/XCreatorTools.java
  79. 16
      designer-form/src/com/fr/design/designer/creator/XElementCase.java
  80. 4
      designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java
  81. 15
      designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  82. 86
      designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  83. 901
      designer-form/src/com/fr/design/designer/creator/XWFitLayout.java
  84. 5
      designer-form/src/com/fr/design/designer/creator/XWParameterLayout.java
  85. 14
      designer-form/src/com/fr/design/designer/creator/XWTitleLayout.java
  86. 7
      designer-form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java
  87. 39
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  88. 244
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  89. 70
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  90. 185
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  91. 126
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  92. 55
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  93. 195
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  94. 48
      designer-form/src/com/fr/design/designer/properties/EventPropertyTable.java
  95. 21
      designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  96. 25
      designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  97. BIN
      designer-form/src/com/fr/design/form/images/joption_failure.png
  98. BIN
      designer-form/src/com/fr/design/form/images/joption_success.png
  99. 7
      designer-form/src/com/fr/design/form/parameter/FormParaDesigner.java
  100. 10
      designer-form/src/com/fr/design/form/util/XCreatorConstants.java
  101. Some files were not shown because too many files have changed in this diff Show More

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

9
designer-base/src/com/fr/design/actions/UpdateAction.java

@ -293,13 +293,20 @@ public abstract class UpdateAction extends ShortCut implements Action {
button.setEnabled(this.isEnabled()); button.setEnabled(this.isEnabled());
//peter:产生tooltip //peter:产生tooltip
button.setToolTipText(ActionFactory.createButtonToolTipText(this)); button.setToolTipText(getToolTipText());
object = button; object = button;
} }
return (JComponent) object; return (JComponent) object;
} }
/**
* 重写此方法可以自定义 action 的提示文字
*/
protected String getToolTipText() {
return ActionFactory.createButtonToolTipText(this);
}
/** /**
* Equals * Equals
*/ */

24
designer-base/src/com/fr/design/actions/file/PreferencePane.java

@ -14,6 +14,7 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -55,6 +56,9 @@ public class PreferencePane extends BasicPane {
private static final int MAX_UNDO_LIMIT_50 = 50; private static final int MAX_UNDO_LIMIT_50 = 50;
private static final int SELECTED_INDEX_4 = 4; private static final int SELECTED_INDEX_4 = 4;
private static final int SELECTED_INDEX_5 = 5; 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 TYPE = "pressed";
private static final String DISPLAY_TYPE = "+"; private static final String DISPLAY_TYPE = "+";
@ -113,6 +117,7 @@ public class PreferencePane extends BasicPane {
private IntegerEditor portEditor; private IntegerEditor portEditor;
private UITextField jdkHomeTextField; private UITextField jdkHomeTextField;
private UICheckBox oracleSpace; private UICheckBox oracleSpace;
private UISpinner cachingTemplateSpinner;
private UICheckBox joinProductImprove; private UICheckBox joinProductImprove;
public PreferencePane() { public PreferencePane() {
@ -173,6 +178,7 @@ public class PreferencePane extends BasicPane {
JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
spaceUpPane.add(oraclePane, BorderLayout.NORTH); spaceUpPane.add(oraclePane, BorderLayout.NORTH);
spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER);
spaceUpPane.add(improvePane, BorderLayout.SOUTH); spaceUpPane.add(improvePane, BorderLayout.SOUTH);
advancePane.add(spaceUpPane); advancePane.add(spaceUpPane);
} }
@ -497,6 +503,20 @@ public class PreferencePane extends BasicPane {
serverPortPane.add(choosePortPane, BorderLayout.CENTER); 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 @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("M_Window-Preference"); return Inter.getLocText("M_Window-Preference");
@ -550,11 +570,12 @@ public class PreferencePane extends BasicPane {
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit()); this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit()); this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
this.portEditor.setValue(new Integer(designerEnvManager.getJettyServerPort())); this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
this.jdkHomeTextField.setText(designerEnvManager.getJdkHome()); this.jdkHomeTextField.setText(designerEnvManager.getJdkHome());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace()); this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove()); this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove());
} }
@ -615,6 +636,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setJdkHome(jdkHomeTextField.getText()); designerEnvManager.setJdkHome(jdkHomeTextField.getText());
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected()); designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());
// designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected()); // designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected());

4
designer-base/src/com/fr/design/actions/help/WebDemoAction.java

@ -4,7 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.start.StartServer; import com.fr.start.ServerStarter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -23,7 +23,7 @@ public class WebDemoAction extends UpdateAction {
* @param evt 事件 * @param evt 事件
*/ */
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
StartServer.browserDemoURL(); ServerStarter.browserDemoURL();
} }
public static final MenuKeySet PRODUCT_DEMO = new MenuKeySet() { public static final MenuKeySet PRODUCT_DEMO = new MenuKeySet() {

1
designer-base/src/com/fr/design/constants/UIConstants.java

@ -108,6 +108,7 @@ public interface UIConstants {
public static final Color AUTHORITY_SHEET_UNSELECTED = new Color(146, 192, 225); public static final Color AUTHORITY_SHEET_UNSELECTED = new Color(146, 192, 225);
public static final Color ATTRIBUTE_PRESS = new Color(0x419BF9); public static final Color ATTRIBUTE_PRESS = new Color(0x419BF9);
public static final Color NORMAL_BLUE = new Color(0x419BF9); public static final Color NORMAL_BLUE = new Color(0x419BF9);
public static final Color DISABLED_ICON_COLOR = new Color(170, 170, 171);
public static final Color ATTRIBUTE_NORMAL = Color.WHITE; public static final Color ATTRIBUTE_NORMAL = Color.WHITE;
public static final Color ATTRIBUTE_HOVER = new Color(0xF5F5F7); public static final Color ATTRIBUTE_HOVER = new Color(0xF5F5F7);
public static final Color UI_TOOLBAR_COLOR = new Color(0xF5F5F7); public static final Color UI_TOOLBAR_COLOR = new Color(0xF5F5F7);

13
designer-base/src/com/fr/design/event/DesignerOpenedListener.java

@ -0,0 +1,13 @@
package com.fr.design.event;
import java.util.EventListener;
/**
* Created by plough on 2018/1/19.
*/
public interface DesignerOpenedListener extends EventListener {
/**
* Invoked when the target of the listener has changed the rpt content.
*/
public void designerOpened();
}

2
designer-base/src/com/fr/design/file/HistoryTemplateListPane.java

@ -35,7 +35,7 @@ import java.util.List;
public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent { public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存 //最大保存内存中面板数,为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 static final int LIST_BORDER = 4;
private List<JTemplate<?, ?>> historyList; private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate; private JTemplate<?, ?> editingTemplate;

3
designer-base/src/com/fr/design/file/MutilTempalteTabPane.java

@ -16,6 +16,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -709,7 +710,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename; filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename;
} }
filename = filename.replaceAll("/", "\\\\"); filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/");
if (!specifiedTemplate.isALLSaved()) { if (!specifiedTemplate.isALLSaved()) {
specifiedTemplate.stopEditing(); specifiedTemplate.stopEditing();

5
designer-base/src/com/fr/design/gui/controlpane/UIListControlPane.java

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

67
designer-base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java

@ -5,6 +5,7 @@ import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -40,7 +41,7 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
* 后台初始化所有事件. * 后台初始化所有事件.
*/ */
public void initAllListeners() { public void initAllListeners() {
initListener(AbstractAttrNoScrollPane.this); initListener(AbstractAttrNoScrollPane.this);
} }
protected void initContentPane() { protected void initContentPane() {
@ -73,14 +74,14 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
} }
if (tmpComp instanceof GlobalNameObserver) { if (tmpComp instanceof GlobalNameObserver) {
((GlobalNameObserver) tmpComp).registerNameListener(new GlobalNameListener() { ((GlobalNameObserver) tmpComp).registerNameListener(new GlobalNameListener() {
public void setGlobalName(String name) { public void setGlobalName(String name) {
globalName = name; globalName = name;
} }
public String getGlobalName() { public String getGlobalName() {
return globalName; return globalName;
} }
}); });
} }
if (tmpComp instanceof UIObserver) { if (tmpComp instanceof UIObserver) {
((UIObserver) tmpComp).registerChangeListener(new UIObserverListener() { ((UIObserver) tmpComp).registerChangeListener(new UIObserverListener() {
@ -93,10 +94,10 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
} }
} }
/** /**
* 是否有改变监听 * 是否有改变监听
* @return 是则返回true * @return 是则返回true
*/ */
public static boolean isHasChangeListener() { public static boolean isHasChangeListener() {
return hasChangeListener; return hasChangeListener;
} }
@ -109,10 +110,10 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
} }
/** /**
* 返回绑定的属性事件. * 返回绑定的属性事件.
* @param listener 增加监听 * @param listener 增加监听
*/ */
public void addAttributeChangeListener(AttributeChangeListener listener) { public void addAttributeChangeListener(AttributeChangeListener listener) {
this.listener = listener; this.listener = listener;
hasChangeListener = true; hasChangeListener = true;
@ -132,13 +133,19 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
/** /**
* 返回图标的路径 * 返回图标的路径
*/ */
public abstract String getIconPath(); public String getIconPath() {
// 默认为空,子类有需要再重写
return StringUtils.EMPTY;
}
/** /**
* 界面标题 * 界面标题
* @return 标题 * @return 标题
*/ */
public abstract String title4PopupWindow(); public String title4PopupWindow() {
// 默认为空,子类有需要再重写
return StringUtils.EMPTY;
}
/** /**
* 设置选中的ID, 用于双击展示界面. * 设置选中的ID, 用于双击展示界面.
@ -151,12 +158,12 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
return globalName; return globalName;
} }
/** /**
* 主要用于图表设计器 * 主要用于图表设计器
* @return * @return
*/ */
public boolean isNeedPresentPaneWhenFilterData(){ public boolean isNeedPresentPaneWhenFilterData(){
return true; return true;
} }
} }

82
designer-base/src/com/fr/design/gui/ibutton/UIRadioButton.java

@ -1,6 +1,14 @@
package com.fr.design.gui.ibutton; package com.fr.design.gui.ibutton;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -9,38 +17,110 @@ import javax.swing.*;
* Date: 13-3-27 * Date: 13-3-27
* Time: 下午5:04 * Time: 下午5:04
*/ */
public class UIRadioButton extends JRadioButton { public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNameObserver {
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
private String radioButtonName = StringUtils.EMPTY;
public UIRadioButton() { public UIRadioButton() {
super(); super();
initListener();
} }
public UIRadioButton(Icon icon) { public UIRadioButton(Icon icon) {
super(icon); super(icon);
initListener();
} }
public UIRadioButton(Action a) { public UIRadioButton(Action a) {
super(a); super(a);
initListener();
} }
public UIRadioButton(Icon icon, boolean selected) { public UIRadioButton(Icon icon, boolean selected) {
super(icon, selected); super(icon, selected);
initListener();
} }
public UIRadioButton(String text) { public UIRadioButton(String text) {
super(text); super(text);
initListener();
} }
public UIRadioButton(String text, boolean selected) { public UIRadioButton(String text, boolean selected) {
super(text, selected); super(text, selected);
initListener();
} }
public UIRadioButton(String text, Icon icon) { public UIRadioButton(String text, Icon icon) {
super(text, icon); super(text, icon);
initListener();
} }
public UIRadioButton(String text, Icon icon, boolean selected) { public UIRadioButton(String text, Icon icon, boolean selected) {
super(text, icon, selected); super(text, icon, selected);
initListener();
}
private void initListener() {
if (shouldResponseChangeListener()) {
this.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (uiObserverListener == null || e.getStateChange() != ItemEvent.SELECTED) {
return;
}
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(radioButtonName);
}
uiObserverListener.doChange();
}
});
}
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;
}
public void setGlobalName(String name) {
radioButtonName = name;
}
public String getGlobalName() {
return radioButtonName;
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseChangeListener() {
return true;
}
/**
* 注册观察者监听事件
* @param listener 观察者监听事件
*/
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}
/**
* 组件是否需要响应观察者事件
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseNameListener() {
return true;
} }
} }

4
designer-base/src/com/fr/design/gui/icheckbox/UICheckBox.java

@ -137,10 +137,12 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
g.setColor(b.getBackground()); g.setColor(b.getBackground());
g.fillRect(0, 0, size.width, size.height); g.fillRect(0, 0, size.width, size.height);
} }
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if ( model.isSelected()) { if ( model.isSelected()) {
GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height,false, Constants.NULL,UIConstants.CHECKBOX_HOVER_SELECTED, 0); GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height,false, Constants.NULL,
model.isEnabled() ? UIConstants.CHECKBOX_HOVER_SELECTED : UIConstants.DISABLED_ICON_COLOR, 0);
} else if (model.isRollover() && ! model.isSelected()) { } else if (model.isRollover() && ! model.isSelected()) {
g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED); g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED);
g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC);

20
designer-base/src/com/fr/design/gui/ispinner/UISpinner.java

@ -12,14 +12,28 @@ import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.plaf.ButtonUI; import javax.swing.plaf.ButtonUI;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver { public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver {

4
designer-base/src/com/fr/design/gui/style/FRFontPane.java

@ -49,7 +49,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private JPanel isSuperOrSubPane; private JPanel isSuperOrSubPane;
private UIComboBox fontNameComboBox; private UIComboBox fontNameComboBox;
private UIComboBox fontSizeStyleComboBox; private UIComboBox fontSizeStyleComboBox;
private UIComboBox fontSizeComboBox; protected UIComboBox fontSizeComboBox;
private UIToggleButton bold; private UIToggleButton bold;
private UIToggleButton italic; private UIToggleButton italic;
private UIToggleButton underline; private UIToggleButton underline;
@ -327,7 +327,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
} }
private JPanel createRightPane() { protected JPanel createRightPane() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {f}; double[] columnSize = {f};

37
designer-base/src/com/fr/design/icon/IconPathConstants.java

@ -1 +1,36 @@
package com.fr.design.icon; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 6.5.6 * Date: 12-12-18 * Time: 上午9:42 * 用于保存所有图标路径的类 */ public class IconPathConstants { private IconPathConstants() { } public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; public static final String TD_EL_SHARE_HELP_ICON_PATH = "/com/fr/design/images/control/help_open.png"; public static final String TD_EL_SHARE_CLOSE_ICON_PATH = "/com/fr/design/images/control/help_close.png"; public static final String TD_REMOVE_ICON_PATH = "/com/fr/design/images/control/tab/remove.png"; public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH = "/com/fr/web/images/form/forbid.png"; } package com.fr.design.icon;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date: 12-12-18
* Time: 上午9:42
* 用于保存所有图标路径的类
*/
public class IconPathConstants {
private IconPathConstants() {
}
public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png";
public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png";
public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png";
public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png";
public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png";
public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png";
public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png";
public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png";
public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png";
public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png";
public static final String TD_EL_SHARE_HELP_ICON_PATH = "/com/fr/design/images/control/help_open.png";
public static final String TD_EL_SHARE_CLOSE_ICON_PATH = "/com/fr/design/images/control/help_close.png";
public static final String TD_REMOVE_ICON_PATH = "/com/fr/design/images/control/tab/remove.png";
public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png";
public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png";
public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png";
public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png";
public static final String FORBID_ICON_PATH = "/com/fr/web/images/form/forbid.png";
public static final String EDIT_ICON_PATH = "/com/fr/design/images/control/newEdit.png";
}

BIN
designer-base/src/com/fr/design/images/control/newEdit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

15
designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java

@ -2,21 +2,20 @@ package com.fr.design.javascript;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fun.JavaScriptActionProvider; import com.fr.design.fun.JavaScriptActionProvider;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.editor.editor.Editor;
import com.fr.form.ui.WebContentUtils; import com.fr.form.ui.WebContentUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -105,7 +104,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
callPane.populateBean(getCall()); callPane.populateBean(getCall());
BasicDialog dialog = callPane.showWindow(DesignerContext.getDesignerFrame()); BasicDialog dialog = callPane.showWindow(SwingUtilities.getWindowAncestor(JavaScriptActionPane.this));
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override

31
designer-base/src/com/fr/design/layout/FRGUIPaneFactory.java

@ -416,6 +416,37 @@ public class FRGUIPaneFactory {
return jp; return jp;
} }
/**
* 创建垂直流布局面板
*
* @param isAlignLeft 是否左对齐
* @return JPanel对象
*/
public static JPanel createVerticalFlowLayout_S_Pane(boolean isAlignLeft) {
JPanel jp = new JPanel();
VerticalFlowLayout layout = new VerticalFlowLayout();
layout.setAlignLeft(isAlignLeft);
jp.setLayout(layout);
return jp;
}
/**
* 创建垂直流布局面板
*
* @param isAlignLeft 是否左对齐
* @param align the alignment value
* @param hgap the horizontal gap between components
* @param vgap the vertical gap between components
* @return JPanel对象
*/
public static JPanel createVerticalFlowLayout_Pane(boolean isAlignLeft, int align, int hgap, int vgap) {
JPanel jp = new JPanel();
VerticalFlowLayout layout = new VerticalFlowLayout(align, hgap, vgap);
layout.setAlignLeft(isAlignLeft);
jp.setLayout(layout);
return jp;
}
/** /**
* 创建边框面板L * 创建边框面板L
* *

55
designer-base/src/com/fr/design/layout/VerticalFlowLayout.java

@ -71,6 +71,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
*/ */
int newAlign; // This is the one we actually use int newAlign; // This is the one we actually use
// 当列宽不一致时,是否需要左对齐(默认居中对齐)
boolean isAlignLeft = false;
/** /**
* The flow layout manager allows a seperation of * The flow layout manager allows a seperation of
* components with gaps. The horizontal gap will * components with gaps. The horizontal gap will
@ -261,9 +264,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
return dim; return dim;
} }
} }
protected boolean dialWithDim4PreferredLayoutSize(Dimension dim, Dimension d, boolean firstVisibleComponent) { protected boolean dialWithDim4PreferredLayoutSize(Dimension dim, Dimension d, boolean firstVisibleComponent) {
dim.width = Math.max(dim.width, d.width); dim.width = Math.max(dim.width, d.width);
if (firstVisibleComponent) { if (firstVisibleComponent) {
firstVisibleComponent = false; firstVisibleComponent = false;
} else { } else {
@ -271,7 +274,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
} }
dim.height += d.height; dim.height += d.height;
return firstVisibleComponent; return firstVisibleComponent;
} }
@ -291,7 +294,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
Dimension dim = new Dimension(0, 0); Dimension dim = new Dimension(0, 0);
int nmembers = target.getComponentCount(); int nmembers = target.getComponentCount();
boolean firstVisibleComponent = true; boolean firstVisibleComponent = true;
for (int i = 0; i < nmembers; i++) { for (int i = 0; i < nmembers; i++) {
Component m = target.getComponent(i); Component m = target.getComponent(i);
if (m.isVisible()) { if (m.isVisible()) {
@ -306,14 +309,14 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
return dim; return dim;
} }
} }
protected boolean dialWithDim4MinimumLayoutSize(Dimension dim, Dimension d, int i, boolean firstVisibleComponent) { protected boolean dialWithDim4MinimumLayoutSize(Dimension dim, Dimension d, int i, boolean firstVisibleComponent) {
dim.width = Math.max(dim.width, d.width); dim.width = Math.max(dim.width, d.width);
if (i > 0) { if (i > 0) {
dim.height += vgap; dim.height += vgap;
} }
dim.height += d.height; dim.height += d.height;
return firstVisibleComponent; return firstVisibleComponent;
} }
@ -345,10 +348,11 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
for (int i = rowStart; i < rowEnd; i++) { for (int i = rowStart; i < rowEnd; i++) {
Component m = target.getComponent(i); Component m = target.getComponent(i);
if (m.isVisible()) { if (m.isVisible()) {
int newX = x + (width - m.getWidth()) / 2;
if (ltr) { if (ltr) {
m.setLocation(x + (width - m.getWidth()) / 2, y); m.setLocation(isAlignLeft ? x : newX, y);
} else { } else {
m.setLocation(x + (width - m.getWidth()) / 2, target.getHeight() - y - m.getHeight()); m.setLocation(isAlignLeft ? x : newX, target.getHeight() - y - m.getHeight());
} }
y += m.getHeight() + vgap; y += m.getHeight() + vgap;
} }
@ -395,17 +399,17 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
dealWithMC4LayoutContainer(target, insets, x, y, roww, start, maxlen, nmembers, ltr); dealWithMC4LayoutContainer(target, insets, x, y, roww, start, maxlen, nmembers, ltr);
} }
} }
protected Dimension getPreferredSize(Container target, Component m) { protected Dimension getPreferredSize(Container target, Component m) {
return m.getPreferredSize(); return m.getPreferredSize();
} }
protected void dealWithMC4LayoutContainer(Container target, Insets insets, int x, int y, int roww, int start, int maxlen, int nmembers, boolean ltr) { protected void dealWithMC4LayoutContainer(Container target, Insets insets, int x, int y, int roww, int start, int maxlen, int nmembers, boolean ltr) {
moveComponents(target, x, insets.top + vgap, roww, maxlen - y, start, nmembers, ltr); moveComponents(target, x, insets.top + vgap, roww, maxlen - y, start, nmembers, ltr);
} }
protected int[] dealWithDim4LayoutContainer(Container target, Insets insets, Dimension d, int x, int y, int roww, int start, int maxlen, int i, boolean ltr) { protected int[] dealWithDim4LayoutContainer(Container target, Insets insets, Dimension d, int x, int y, int roww, int start, int maxlen, int i, boolean ltr) {
if ((y == 0) || ((y + d.height) <= maxlen)) { if ((y == 0) || ((y + d.height) <= maxlen)) {
if (y > 0) y += vgap; if (y > 0) y += vgap;
y += d.height; y += d.height;
roww = Math.max(roww, d.width); roww = Math.max(roww, d.width);
@ -416,19 +420,26 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable {
roww = d.width; roww = d.width;
start = i; start = i;
} }
return new int[]{x, y, roww, start}; return new int[]{x, y, roww, start};
} }
protected int getMaxLen4LayoutContainer(Container target, Insets insets) { protected int getMaxLen4LayoutContainer(Container target, Insets insets) {
return target.getHeight() - (insets.top + insets.bottom + vgap * 2); return target.getHeight() - (insets.top + insets.bottom + vgap * 2);
} }
protected int getX4LayoutContainer(Insets insets) { protected int getX4LayoutContainer(Insets insets) {
return insets.left + hgap; return insets.left + hgap;
} }
protected int getY4LayoutContainer(Insets insets) { protected int getY4LayoutContainer(Insets insets) {
return 0; return 0;
}
/**
* 当列宽不一致时通过此方法设置是否需要左对齐
*/
public void setAlignLeft(boolean isAlignLeft) {
this.isAlignLeft = true;
} }

38
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -7,6 +7,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.EnvConfigUtils; import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
@ -16,6 +17,7 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
@ -95,6 +97,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private static final Integer TOP_LAYER = new Integer((200)); private static final Integer TOP_LAYER = new Integer((200));
private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>(); private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>();
private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>();
private ToolBarMenuDock ad; private ToolBarMenuDock ad;
private DesktopCardPane centerTemplateCardPane; private DesktopCardPane centerTemplateCardPane;
@ -287,6 +291,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
/**
* 注册"设计器初始化完成"的监听
*/
public void addDesignerOpenedListener(DesignerOpenedListener listener) {
designerOpenedListenerList.add(listener);
}
/**
* 触发"设计器初始化完成"事件
*/
public void fireDesignerOpened() {
for (DesignerOpenedListener listener : designerOpenedListenerList) {
listener.designerOpened();
}
}
protected DesktopCardPane getCenterTemplateCardPane() { protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane; return centerTemplateCardPane;
} }
@ -317,7 +337,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void on(PluginEvent event) { public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad); refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv()); DesignUtils.refreshDesignerFrame();
} }
}, new PluginFilter() { }, new PluginFilter() {
@ -682,10 +702,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 报表运行环境改变时,需要刷新某些面板 * 报表运行环境改变时,需要刷新某些面板
*
* @param env 环境
*/ */
public void refreshEnv(Env env) { public void refreshEnv() {
this.setTitle(); this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView(); DesignerFrameFileDealerPane.getInstance().refreshDockingView();
@ -929,8 +947,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} else { } else {
this.addAndActivateJTemplate(jt); this.addAndActivateJTemplate(jt);
} }
//REPORT-5084:激活后刷新一下右側面板
jt.refreshEastPropertiesPane();
} }
/** /**
@ -965,14 +981,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
Env currentEnv = FRContext.getCurrentEnv(); EnvContext.signOut();
try {
EventDispatcher.fire(BEFORE_SIGN_OUT);
currentEnv.signOut();
EventDispatcher.fire(AFTER_SIGN_OUT);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
this.setVisible(false); this.setVisible(false);
this.dispose(); this.dispose();

16
designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -81,7 +82,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
* *
* @return * @return
*/ */
public static final EastRegionContainerPane getInstance() { public static EastRegionContainerPane getInstance() {
if (THIS == null) { if (THIS == null) {
THIS = new EastRegionContainerPane(); THIS = new EastRegionContainerPane();
THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastEastRegionContainerWidth()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastEastRegionContainerWidth());
@ -230,6 +231,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
updateAllPropertyPane(); updateAllPropertyPane();
} }
/**
* 可通过此方法判断当前的编辑模式
* */
public PropertyMode getCurrentMode() {
return currentMode;
}
public void updateAllPropertyPane() { public void updateAllPropertyPane() {
updatePropertyItemMap(); updatePropertyItemMap();
initContentPane(); initContentPane();
@ -357,10 +365,6 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane); propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane);
} }
public void setParameterHeight(int height) {
// stub
}
public static void main(String[] args){ public static void main(String[] args){
JFrame jf = new JFrame("test"); JFrame jf = new JFrame("test");
// jf = new JFrame("test"); // jf = new JFrame("test");
@ -436,7 +440,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 无可用 tab 时,显示提示文字 // 无可用 tab 时,显示提示文字
if (!hasAvailableTab) { if (!hasAvailableTab) {
resetPropertyIcons(); resetPropertyIcons();
if (!hasEnabledTab && BaseUtils.isAuthorityEditing()) { if (!hasEnabledTab && DesignerMode.isAuthorityEditing()) {
propertyCard.show(rightPane, DEFAULT_AUTHORITY_PANE); propertyCard.show(rightPane, DEFAULT_AUTHORITY_PANE);
} else { } else {
propertyCard.show(rightPane, DEFAULT_PANE); propertyCard.show(rightPane, DEFAULT_PANE);

27
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.UIRadioButton;
import com.fr.design.gui.ibutton.UISliderButton; import com.fr.design.gui.ibutton.UISliderButton;
import com.fr.design.gui.ilable.UILabel; 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.islider.UISlider;
import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.ispinner.UISpinnerUI; import com.fr.design.gui.ispinner.UISpinnerUI;
@ -21,7 +22,6 @@ import javax.swing.JButton;
import javax.swing.JFormattedTextField; import javax.swing.JFormattedTextField;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.JSpinner; import javax.swing.JSpinner;
@ -41,6 +41,7 @@ import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -59,22 +60,15 @@ public class JSliderPane extends JPanel {
private static final double ONEPOINTEIGHT = 1.8; private static final double ONEPOINTEIGHT = 1.8;
private static final int SIX = 6; private static final int SIX = 6;
private static final int TEN = 10; private static final int TEN = 10;
private static final int ONE_EIGHT = 18;
private static final int FONT_SIZE = 12; private static final int FONT_SIZE = 12;
private static final int SPINNER_WIDTH = 45; private static final int SPINNER_WIDTH = 45;
private static final int SPINNER_HEIGHT = 20; private static final int SPINNER_HEIGHT = 20;
private static final int HALF_HUNDRED = 50; private static final int HALF_HUNDRED = 50;
private static final int HUNDRED = 100; private static final int HUNDRED = 100;
private static final int TWO_HUNDRED = 200; 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 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_WIDTH = 40;
private static final int SHOWVALBUTTON_HEIGHTH = 20; private static final int SHOWVALBUTTON_HEIGHTH = 20;
private static final int SLIDER_GAP = 5;
private static final int TOOLTIP_Y = 30; private static final int TOOLTIP_Y = 30;
private static final Color BACK_COLOR = new Color(245, 245, 247); private static final Color BACK_COLOR = new Color(245, 245, 247);
@ -427,14 +421,14 @@ public class JSliderPane extends JPanel {
dialog = new PopupPane(upButton, dialogContentPanel); dialog = new PopupPane(upButton, dialogContentPanel);
if (upButtonX == 0) { if (upButtonX == 0) {
upButtonX = btnCoords.x; 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 { } else {
if (upButtonX == 0) { if (upButtonX == 0) {
upButtonX = btnCoords.x; 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 { } 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);
} }
} }
} }
@ -503,9 +497,12 @@ class JSliderPaneUI extends BasicSliderUI {
} }
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_WIDTH = 157;
private static final int DIALOG_HEIGHT = 192; private static final int DIALOG_HEIGHT = 205;
PopupPane(JButton b, JPanel dialogContentPanel) { PopupPane(JButton b, JPanel dialogContentPanel) {
this.add(dialogContentPanel, BorderLayout.CENTER); this.add(dialogContentPanel, BorderLayout.CENTER);
@ -513,5 +510,7 @@ class PopupPane extends JPopupMenu {
this.setBackground(new Color(245, 245, 247)); this.setBackground(new Color(245, 245, 247));
} }
public Insets getInsets() {
return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT);
}
} }

30
designer-base/src/com/fr/design/mainframe/JTemplate.java

@ -557,15 +557,25 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
operation == FILEChooserPane.OK_OPTION; operation == FILEChooserPane.OK_OPTION;
} }
private boolean saveAsTemplate(boolean isShowLoc) { public boolean saveAsTemplate(boolean isShowLoc) {
FILE editingFILE = this.getEditingFILE(); FILE editingFILE = this.getEditingFILE();
if (editingFILE == null) { if (editingFILE == null) {
return false; return false;
} }
return saveAsTemplate(isShowLoc, editingFILE.getName());
}
/**
* 保存
* @param isShowLoc 是否显示报表运行环境外的路径(C盘D盘等)
* @param fileName 保存文件名
* @return
*/
public boolean saveAsTemplate(boolean isShowLoc, String fileName) {
String oldName = this.getFullPathName(); String oldName = this.getFullPathName();
// alex:如果是SaveAs的话需要让用户来选择路径了 // alex:如果是SaveAs的话需要让用户来选择路径了
FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc); FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc);
fileChooser.setFileNameTextField(editingFILE.getName(), this.suffix()); fileChooser.setFileNameTextField(fileName, this.suffix());
int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix());
if (isCancelOperation(chooseResult)) { if (isCancelOperation(chooseResult)) {
@ -574,7 +584,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
if (isOkOperation(chooseResult)) { if (isOkOperation(chooseResult)) {
if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath())) { if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE);
return false; return false;
} }
@ -1000,10 +1010,24 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return UIConstants.RUN_BIG_ICON; return UIConstants.RUN_BIG_ICON;
} }
/**
* 获取所有参数
*
* @return
*/
public Parameter[] getParameters() { public Parameter[] getParameters() {
return new Parameter[0]; return new Parameter[0];
} }
/**
* 获取模板参数
*
* @return
*/
public Parameter[] getJTemplateParameters() {
return new Parameter[0];
}
/** /**
* 请求表单焦点 * 请求表单焦点
*/ */

4
designer-base/src/com/fr/design/mainframe/JVirtualTemplate.java

@ -12,6 +12,7 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -41,7 +42,8 @@ public class JVirtualTemplate extends JTemplate {
if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName; editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName;
} }
return editingFileName.replaceAll("/", "\\\\"); editingFileName = OperatingSystem.isWindows() ? editingFileName.replaceAll("/", "\\\\") : editingFileName.replaceAll("\\\\", "/");
return editingFileName;
} }
/** /**

2
designer-base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java

@ -47,7 +47,7 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane {
public ImageBackgroundQuickPane(boolean hasImageLayout) { public ImageBackgroundQuickPane(boolean hasImageLayout) {
this.setLayout(new BorderLayout(0, 4)); this.setLayout(new BorderLayout(0, 4));
String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Extend"), Inter.getLocText("FR-Background_Image_Adjust")};
Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST};
imageLayoutPane = new UIButtonGroup<Byte>(nameArray, valueArray); imageLayoutPane = new UIButtonGroup<Byte>(nameArray, valueArray);
imageLayoutPane.setSelectedIndex(0); imageLayoutPane.setSelectedIndex(0);

7
designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ServerConfig;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
@ -38,9 +37,9 @@ import java.util.logging.LogRecord;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class DesignerLogHandler { public class DesignerLogHandler {
protected static final int INFO_INT = com.fr.third.apache.log4j.Level.INFO.toInt(); protected static final int INFO_INT = Level.INFO.intValue();
protected static final int ERROR_INT = com.fr.third.apache.log4j.Level.ERROR.toInt(); protected static final int ERROR_INT = Level.SEVERE.intValue();
protected static final int WARN_INT = com.fr.third.apache.log4j.Level.WARN.toInt(); protected static final int WARN_INT = Level.WARNING.intValue();
private static final int GAP_X = -150; private static final int GAP_X = -150;
private static final int INFO_GAP_Y = -60; private static final int INFO_GAP_Y = -60;
private static final int ERRO_GAP_Y = -40; private static final int ERRO_GAP_Y = -40;

9
designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java

@ -10,7 +10,6 @@ import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.LogRecordTime; import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils; import com.fr.general.LogUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -43,18 +42,18 @@ public class DesignerSocketIO {
}; };
static { static {
EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener<Null>() { EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener<EnvConfig>() {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, EnvConfig param) {
if (socketIO.isPresent()) { if (socketIO.isPresent()) {
socketIO.get().close(); socketIO.get().close();
socketIO = Optional.absent(); socketIO = Optional.absent();
} }
} }
}); });
EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener<Null>() { EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener<EnvConfig>() {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, EnvConfig param) {
updateSocket(); updateSocket();
} }
}); });

30
designer-base/src/com/fr/design/mainframe/widget/BasicPropertyPane.java

@ -13,6 +13,10 @@ import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/** /**
* Created by plough on 2017/8/7. * Created by plough on 2017/8/7.
@ -27,7 +31,31 @@ public class BasicPropertyPane extends BasicPane {
protected void initContentPane() { protected void initContentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
widgetName = new UITextField(); widgetName = new UITextField() {
protected void initListener() {
if (shouldResponseChangeListener()) {
addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
attributeChange();
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
attributeChange();
}
}
});
}
}
};
widgetName.setGlobalName(Inter.getLocText("FR-Designer_Basic")); widgetName.setGlobalName(Inter.getLocText("FR-Designer_Basic"));
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;

14
designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java

@ -1,14 +1,15 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import java.awt.Dimension;
import javax.swing.SwingUtilities;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.style.background.BackgroundButtonPane; import com.fr.design.style.background.BackgroundButtonPane;
import com.fr.general.Background; import com.fr.general.Background;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
private BackgroundButtonPane choosePane; private BackgroundButtonPane choosePane;
@ -18,7 +19,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
@Override @Override
protected void showEditorPane() { protected void showEditorPane() {
choosePane = new BackgroundButtonPane(); choosePane = initBackgroundPane();
choosePane.setPreferredSize(new Dimension(600, 400)); choosePane.setPreferredSize(new Dimension(600, 400));
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() { dlg.addDialogActionListener(new DialogActionAdapter() {
@ -32,4 +33,9 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
dlg.setVisible(true); dlg.setVisible(true);
} }
protected BackgroundButtonPane initBackgroundPane(){
return new BackgroundButtonPane();
}
} }

18
designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java

@ -0,0 +1,18 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.style.background.BackgroundButtonPane;
import com.fr.design.style.background.BackgroundCardSwitchButtonPane;
/**
* @author kerry
* @date 2018/1/29
*/
public class AccessibleTabBackgroundEditor extends AccessibleImgBackgroundEditor {
public AccessibleTabBackgroundEditor() {
super();
}
@Override
protected BackgroundButtonPane initBackgroundPane(){
return new BackgroundCardSwitchButtonPane();
}
}

40
designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java

@ -0,0 +1,40 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.base.background.ColorBackground;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.style.background.BackgroundTabPane;
import com.fr.general.Background;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
/**
* @author kerry
* @date 2018/1/17
*/
public class AccessibleTabPaneBackgroundEditor extends UneditableAccessibleEditor {
private BackgroundTabPane choosePane;
public AccessibleTabPaneBackgroundEditor() {
super(new BackgroundWrapper());
}
@Override
protected void showEditorPane() {
choosePane = new BackgroundTabPane();
choosePane.setPreferredSize(new Dimension(600, 400));
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(choosePane.update());
fireStateChanged();
}
});
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
dlg.setVisible(true);
}
}

14
designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java

@ -1,17 +1,17 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.general.cardtag.BannerTemplateStyle; import com.fr.general.cardtag.BannerTemplateStyle;
import com.fr.general.cardtag.BookMarkTemplateStyle; import com.fr.general.cardtag.BookMarkTemplateStyle;
import com.fr.general.cardtag.CardTemplateStyle; import com.fr.general.cardtag.CardTemplateStyle;
import com.fr.general.cardtag.DefaultTemplateStyle; import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.MenuTemplateStyle; import com.fr.general.cardtag.MenuTemplateStyle;
import com.fr.general.cardtag.PentagonTemplateStyle; 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.general.cardtag.TemplateStyle;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.cardtag.TrapezoidTemplateStyle;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
@ -41,11 +41,11 @@ public class TemplateStylePane extends BasicPane {
listModel = new DefaultListModel(); listModel = new DefaultListModel();
listModel.addElement(new DefaultTemplateStyle()); listModel.addElement(new DefaultTemplateStyle());
listModel.addElement(new CardTemplateStyle()); listModel.addElement(new CardTemplateStyle());
listModel.addElement(new BannerTemplateStyle());
listModel.addElement(new BookMarkTemplateStyle()); listModel.addElement(new BookMarkTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new MenuTemplateStyle()); listModel.addElement(new MenuTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new TrapezoidTemplateStyle()); listModel.addElement(new TrapezoidTemplateStyle());
listModel.addElement(new BannerTemplateStyle());
styleList = new JList(listModel); styleList = new JList(listModel);
styleList.setCellRenderer(render); styleList.setCellRenderer(render);

5
designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java

@ -14,7 +14,8 @@ import java.awt.Image;
public class TemplateStylePreviewPane extends JPanel { public class TemplateStylePreviewPane extends JPanel {
private static final int WIDTH = 540; private static final int WIDTH = 540;
private static final int HEIGHT = 500; private static final int HEIGHT = 400;
private static final int OFFSETY = 50;
private TemplateStyle templateStyle; private TemplateStyle templateStyle;
@ -32,6 +33,6 @@ public class TemplateStylePreviewPane extends JPanel {
super.paint(g); super.paint(g);
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
Image image = BaseUtils.readImage(templateStyle.getPreview()); Image image = BaseUtils.readImage(templateStyle.getPreview());
g2d.drawImage(image, 0, 0, WIDTH, HEIGHT, null); g2d.drawImage(image, 0, OFFSETY, WIDTH, HEIGHT, null);
} }
} }

95
designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java

@ -0,0 +1,95 @@
package com.fr.design.style.background;
import com.fr.base.background.ColorBackground;
import com.fr.base.background.GradientBackground;
import com.fr.base.background.ImageBackground;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.design.style.background.impl.ColorBackgroundPane;
import com.fr.design.style.background.impl.ImageBackgroundPane;
import com.fr.design.style.background.impl.NullBackgroundPane;
import com.fr.general.Background;
import com.fr.general.Inter;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author kerry
* @date 2018/1/29
*/
public class BackgroundCardSwitchButtonPane extends BackgroundButtonPane {
private static Map<Class<? extends Background>, BackgroundUIWrapper> cardSwitchButton = new LinkedHashMap<>();
static {
registerCardSwitchBtnBackground(cardSwitchButton);
}
private static void registerCardSwitchBtnBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(ColorBackground.class, BackgroundUIWrapper.create()
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color")));
map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
map.put(GradientBackground.class, BackgroundUIWrapper.create()
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color")));
}
public BackgroundCardSwitchButtonPane() {
super();
}
@Override
protected void initTabPane() {
int index = 0;
for (Class<? extends Background> key : cardSwitchButton.keySet()) {
BackgroundUIWrapper wrapper = cardSwitchButton.get(key);
wrapper.setIndex(index++);
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
}
}
@Override
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) {
return cardSwitchButton.get(background == null ? null : background.getClass());
}
@Override
protected BackgroundDetailPane getTabItemPane(Background background, int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background);
quickPane = BackgroundFactory.createByWrapper(uiWrapper);
quickPane.addChangeListener(backgroundChangeListener);
cacheMap.put(index, quickPane);
}
tabbedPane.setComponentAt(index, quickPane);
tabbedPane.setSelectedIndex(index);
return quickPane;
}
@Override
protected BackgroundDetailPane getTabItemPaneByIndex(int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
quickPane = createDetailPaneByIndex(index);
tabbedPane.setComponentAt(index, quickPane);
cacheMap.put(index, quickPane);
quickPane.addChangeListener(backgroundChangeListener);
}
return quickPane;
}
public BackgroundDetailPane createDetailPaneByIndex(int index) {
for (BackgroundUIWrapper wrapper : cardSwitchButton.values()) {
if (wrapper.getIndex() == index) {
return BackgroundFactory.createByWrapper(wrapper);
}
}
return new NullBackgroundPane();
}
}

74
designer-base/src/com/fr/design/style/background/BackgroundFactory.java

@ -1,13 +1,29 @@
package com.fr.design.style.background; package com.fr.design.style.background;
import com.fr.base.background.*; import com.fr.base.background.ColorBackground;
import com.fr.base.background.GradientBackground;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.PatternBackground;
import com.fr.base.background.TextureBackground;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.BackgroundUIProvider; import com.fr.design.fun.BackgroundUIProvider;
import com.fr.design.style.background.gradient.GradientBackgroundPane; import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.design.style.background.impl.*; import com.fr.design.style.background.impl.ColorBackgroundPane;
import com.fr.design.style.background.impl.ImageBackgroundPane;
import com.fr.design.style.background.impl.ImageBackgroundPane4Browser;
import com.fr.design.style.background.impl.ImageButtonBackgroundPane;
import com.fr.design.style.background.impl.NullBackgroundPane;
import com.fr.design.style.background.impl.PatternBackgroundPane;
import com.fr.design.style.background.impl.TextureBackgroundPane;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@ -29,9 +45,51 @@ public class BackgroundFactory {
registerBrowserImageBackground(browser); registerBrowserImageBackground(browser);
registerExtra(map); registerExtra(map);
registerExtra(browser); registerExtra(browser);
listenPlugin();
registerButtonBackground(button); registerButtonBackground(button);
} }
private static void listenPlugin() {
PluginFilter filter = new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(BackgroundUIProvider.MARK_STRING);
}
};
GeneralContext.listenPlugin(PluginEventType.BeforeStop, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
Set<BackgroundUIProvider> set = event.getContext().getRuntime().get(BackgroundUIProvider.MARK_STRING);
for (BackgroundUIProvider provider : set) {
map.remove(provider.targetClass());
browser.remove(provider.targetClass());
}
}
}, filter);
GeneralContext.listenPlugin(PluginEventType.AfterRun, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
Set<BackgroundUIProvider> set = event.getContext().getRuntime().get(BackgroundUIProvider.MARK_STRING);
Class<? extends Background> clazz;
BackgroundUIWrapper wrapper;
for (BackgroundUIProvider provider : set) {
clazz = provider.targetClass();
wrapper = BackgroundUIWrapper.create().setType(provider.targetUIClass()).setTitle(provider.targetTitle());
map.put(clazz, wrapper);
browser.put(clazz, wrapper);
}
}
});
}
private static void registerUniversal(Map<Class<? extends Background>, BackgroundUIWrapper> map) { private static void registerUniversal(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(null, BackgroundUIWrapper.create() map.put(null, BackgroundUIWrapper.create()
.setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null"))); .setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null")));
@ -46,19 +104,19 @@ public class BackgroundFactory {
} }
private static void registerImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) { private static void registerImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(ImageFileBackground.class, BackgroundUIWrapper.create() map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); .setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
} }
private static void registerBrowserImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) { private static void registerBrowserImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(ImageFileBackground.class, BackgroundUIWrapper.create() map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); .setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
} }
private static void registerButtonBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) { private static void registerButtonBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map){
map.put(ColorBackground.class, BackgroundUIWrapper.create() map.put(ColorBackground.class, BackgroundUIWrapper.create()
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color"))); .setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color")));
map.put(ImageFileBackground.class, BackgroundUIWrapper.create() map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageButtonBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); .setType(ImageButtonBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
} }
@ -139,7 +197,7 @@ public class BackgroundFactory {
return new NullBackgroundPane(); return new NullBackgroundPane();
} }
private static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) { public static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) {
Class<? extends BackgroundDetailPane> clazz = wrapper.getType(); Class<? extends BackgroundDetailPane> clazz = wrapper.getType();
if (clazz == null) { if (clazz == null) {
clazz = NullBackgroundPane.class; clazz = NullBackgroundPane.class;

88
designer-base/src/com/fr/design/style/background/BackgroundTabPane.java

@ -0,0 +1,88 @@
package com.fr.design.style.background;
import com.fr.base.background.ColorBackground;
import com.fr.base.background.GradientBackground;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.design.style.background.impl.ColorBackgroundPane;
import com.fr.design.style.background.impl.NullBackgroundPane;
import com.fr.general.Background;
import com.fr.general.Inter;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author kerry
* @date 2018/1/17
*/
public class BackgroundTabPane extends BackgroundPane {
private static Map<Class<? extends Background>, BackgroundUIWrapper> tabpane = new LinkedHashMap<>();
static {
registerTabpaneBackground(tabpane);
}
private static void registerTabpaneBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(null, BackgroundUIWrapper.create()
.setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null")));
map.put(ColorBackground.class, BackgroundUIWrapper.create()
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color")));
map.put(GradientBackground.class, BackgroundUIWrapper.create()
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color")));
}
public BackgroundTabPane() {
super();
}
protected void initTabPane() {
int index = 0;
for (Class<? extends Background> key : tabpane.keySet()) {
BackgroundUIWrapper wrapper = tabpane.get(key);
wrapper.setIndex(index++);
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
}
}
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) {
return tabpane.get(background == null ? null : background.getClass());
}
protected BackgroundDetailPane getTabItemPane(Background background, int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background);
quickPane = BackgroundFactory.createByWrapper(uiWrapper);
quickPane.addChangeListener(backgroundChangeListener);
cacheMap.put(index, quickPane);
}
tabbedPane.setComponentAt(index, quickPane);
tabbedPane.setSelectedIndex(index);
return quickPane;
}
protected BackgroundDetailPane getTabItemPaneByIndex(int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
quickPane = createDetailPaneByIndex(index);
tabbedPane.setComponentAt(index, quickPane);
cacheMap.put(index, quickPane);
quickPane.addChangeListener(backgroundChangeListener);
}
return quickPane;
}
public BackgroundDetailPane createDetailPaneByIndex(int index) {
for (BackgroundUIWrapper wrapper : tabpane.values()) {
if (wrapper.getIndex() == index) {
return BackgroundFactory.createByWrapper(wrapper);
}
}
return new NullBackgroundPane();
}
}

44
designer-base/src/com/fr/design/utils/DesignUtils.java

@ -1,15 +1,15 @@
package com.fr.design.utils; package com.fr.design.utils;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.EnvException; import com.fr.base.EnvException;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.FeedBackInfo; import com.fr.base.FeedBackInfo;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.dav.DavXMLUtils; import com.fr.dav.DavXMLUtils;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.fun.DesignerEnvProcessor;
@ -29,10 +29,13 @@ import com.fr.stable.CodeUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.start.StartServer; import com.fr.start.ServerStarter;
import javax.swing.*; import javax.swing.JOptionPane;
import java.awt.*; import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Desktop;
import java.awt.Font;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -142,7 +145,7 @@ public class DesignUtils {
String line = null; String line = null;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
if (line.startsWith("demo")) { if (line.startsWith("demo")) {
StartServer.browserDemoURL(); ServerStarter.browserDemoURL();
} else if (StringUtils.isNotEmpty(line)) { } else if (StringUtils.isNotEmpty(line)) {
File f = new File(line); File f = new File(line);
String path = f.getAbsolutePath(); String path = f.getAbsolutePath();
@ -184,20 +187,16 @@ public class DesignUtils {
}); });
} }
/** /**
* 当前的报表运行环境切换到env * 当前的报表运行环境切换到env
* *
* @param env 需要切换去的环境 * @param env 需要切换去的环境
*/ */
public static void switchToEnv(Env env) { public static void switchToEnv(EnvConfig env) {
if (env == null) { if (env == null) {
return; return;
} }
Env oldEnv = FRContext.getCurrentEnv();
String oldEnvPath = oldEnv == null ? null : oldEnv.getPath();
// 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName // 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
java.util.Iterator<String> nameIt = envManager.getEnvNameIterator(); java.util.Iterator<String> nameIt = envManager.getEnvNameIterator();
@ -208,20 +207,11 @@ public class DesignUtils {
break; break;
} }
} }
EnvContext.signIn(env);
// 更新CurrentEnv于FRContext & DesignerEnvManager refreshDesignerFrame();
FRContext.setCurrentEnv(env);
refreshDesignerFrame(env);
// 当换了运行环境,重置服务器,让它下次预览时重启
if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) {
StartServer.currentEnvChanged();
}
} }
public static void refreshDesignerFrame(Env env) { public static void refreshDesignerFrame() {
final Env run_env = env;
// 刷新DesignerFrame里面的面板 // 刷新DesignerFrame里面的面板
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@ -230,7 +220,7 @@ public class DesignUtils {
if (DesignerContext.getDesignerFrame() == null) { if (DesignerContext.getDesignerFrame() == null) {
return; return;
} }
DesignerContext.getDesignerFrame().refreshEnv(run_env); DesignerContext.getDesignerFrame().refreshEnv();
DesignerContext.getDesignerFrame().repaint();// kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变. DesignerContext.getDesignerFrame().repaint();// kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变.
} }
}); });
@ -358,10 +348,10 @@ public class DesignUtils {
} else { } else {
try { try {
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort()
+ "/" + web + "/" + ServerConfig.getInstance().getServletName() + baseRoute + "/" + web + "/" + ServerConfig.getInstance().getServletName() + baseRoute
+ postfixOfUri; + postfixOfUri;
StartServer.browserURLWithLocalEnv(url); ServerStarter.browserURLWithLocalEnv(url);
} catch (Throwable e) { } catch (Throwable e) {
// //
} }
@ -524,4 +514,4 @@ public class DesignUtils {
} }
} }

47
designer-base/src/com/fr/design/utils/gui/GUICoreUtils.java

@ -12,6 +12,7 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.EditTextField; import com.fr.design.gui.itextfield.EditTextField;
@ -37,6 +38,7 @@ import javax.swing.tree.TreePath;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
@ -844,4 +846,49 @@ public abstract class GUICoreUtils{
&& oneRect.getWidth() == otherRect.getWidth() && oneRect.getWidth() == otherRect.getWidth()
&& oneRect.getHeight() == otherRect.getHeight(); && oneRect.getHeight() == otherRect.getHeight();
} }
/**
* 生成提示标签
* @param tipText 提示文字
* @return UILabel 标签对象
*/
public static UILabel createTipLabel(String tipText) {
UILabel tipLabel = new UILabel("<html>" + tipText + "</html>");
tipLabel.setForeground(Color.gray);
return tipLabel;
}
/**
* 生成没有边框的 UICheckBox
* @param text 说明文字
* @return UICheckBox
*/
public static UICheckBox createNoBorderCheckBox(String text) {
UICheckBox checkBox = new UICheckBox(text);
checkBox.setBorder(BorderFactory.createEmptyBorder());
return checkBox;
}
/**
* 创建包含选择框和一个动态面板的联动面板根据选择框的状态动态面板会动态地显示或隐藏
* @param checkBox 选择框
* @param dynamicPane 包含任意内容的动态面板
* @param hideOnSelected 选中时隐藏动态面板若为false则在"去掉勾选"时隐藏动态面板
* @return 联动面板
*/
public static JPanel createCheckboxAndDynamicPane(UICheckBox checkBox, final JPanel dynamicPane, final boolean hideOnSelected) {
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
int visibleState = hideOnSelected ? ItemEvent.DESELECTED : ItemEvent.SELECTED;
dynamicPane.setVisible(e.getStateChange() == visibleState);
}
});
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(checkBox, BorderLayout.NORTH);
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
dynamicPaneWrapper.add(dynamicPane);
panel.add(dynamicPaneWrapper, BorderLayout.CENTER);
return panel;
}
} }

24
designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java

@ -11,8 +11,10 @@ import com.fr.design.mainframe.widget.accessibles.AccessibleImgBackgroundEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/** /**
* Created by ibm on 2017/8/6. * Created by ibm on 2017/8/6.
@ -31,9 +33,7 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel headLabel = createUILable(); UILabel headLabel = createUILable();
initialBackgroundEditor = new AccessibleImgBackgroundEditor(); initBackgroundEditor();
overBackgroundEditor = new AccessibleImgBackgroundEditor();
clickBackgroundEditor = new AccessibleImgBackgroundEditor();
String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")}; String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")};
double f = TableLayout.FILL; double f = TableLayout.FILL;
@ -44,9 +44,9 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Initial")), initialBackgroundEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Initial")), initialBackgroundEditor},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Over")), overBackgroundEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Over")), overBackgroundEditor},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Click")), clickBackgroundEditor}, new Component[]{getClickLabel(), clickBackgroundEditor},
}; };
panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0)); panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0));
backgroundHead = new UIButtonGroup(titles); backgroundHead = new UIButtonGroup(titles);
JPanel headPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ JPanel headPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
@ -57,6 +57,16 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
} }
protected void initBackgroundEditor(){
initialBackgroundEditor = new AccessibleImgBackgroundEditor();
overBackgroundEditor = new AccessibleImgBackgroundEditor();
clickBackgroundEditor = new AccessibleImgBackgroundEditor();
}
protected UILabel getClickLabel(){
return new UILabel(Inter.getLocText("FR-Designer_Background-Click"));
}
protected UILabel createUILable(){ protected UILabel createUILable(){
return new UILabel(Inter.getLocText("FR-Designer_Background")); return new UILabel(Inter.getLocText("FR-Designer_Background"));
} }

28
designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java

@ -9,9 +9,10 @@ import com.fr.stable.StringUtils;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboBoxUI;
import java.awt.*; import java.awt.Dimension;
import java.awt.event.FocusEvent; import java.awt.Insets;
import java.awt.event.FocusListener; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/** /**
* Created by kerry on 2017/9/14. * Created by kerry on 2017/9/14.
@ -66,14 +67,29 @@ public class UIComboBoxNoArrow extends UIComboBox {
super(); super();
this.comboBox = comboBox; this.comboBox = comboBox;
textField.getDocument().addDocumentListener(this); textField.getDocument().addDocumentListener(this);
textField.addFocusListener(new FocusListener() { textField.addMouseListener(new MouseListener() {
@Override @Override
public void focusGained(FocusEvent e) { public void mouseClicked(MouseEvent e) {
changeHandler(); changeHandler();
} }
@Override @Override
public void focusLost(FocusEvent e) { public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
} }
}); });

28
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -2,7 +2,10 @@ package com.fr.env;
import com.fr.base.EnvException; import com.fr.base.EnvException;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.operator.file.FileOperator;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
import com.fr.common.rpc.netty.MessageSendExecutor;
import com.fr.common.rpc.serialize.RpcSerializeProtocol;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext; import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.core.env.resource.RemoteEnvConfig;
@ -41,6 +44,7 @@ import com.fr.stable.SvgProvider;
import com.fr.stable.file.XMLFileManagerProvider; import com.fr.stable.file.XMLFileManagerProvider;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.third.guava.base.Strings;
import com.fr.third.guava.collect.ImmutableMap; import com.fr.third.guava.collect.ImmutableMap;
import com.fr.web.ResourceConstants; import com.fr.web.ResourceConstants;
@ -75,6 +79,7 @@ import static com.fr.third.guava.base.Preconditions.checkArgument;
* @author null * @author null
*/ */
public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable { public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable {
private static final String CERT_KEY = "javax.net.ssl.trustStore"; private static final String CERT_KEY = "javax.net.ssl.trustStore";
private static final String PWD_KEY = "javax.net.ssl.trustStorePassword"; private static final String PWD_KEY = "javax.net.ssl.trustStorePassword";
private static final String HTTPS_PREFIX = "https:"; private static final String HTTPS_PREFIX = "https:";
@ -87,6 +92,23 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
env = new RemoteEnvConfig(path, userName, password); env = new RemoteEnvConfig(path, userName, password);
} }
@Override
public void connect() {
// FIXME:richie ip地址属于测试的,带实际修改为RemoteEnv配置的地址
MessageSendExecutor.getInstance().setRpcServerLoader("127.0.0.1:" + 33999, RpcSerializeProtocol.KRYOSERIALIZE);
}
@Override
public boolean disconnect() {
MessageSendExecutor.getInstance().stop();
return true;
}
@Override
public FileOperator getFileOperator() throws Exception {
return MessageSendExecutor.getInstance().execute(FileOperator.class);
}
@Override @Override
public String getPath() { public String getPath() {
return env.getPath(); return env.getPath();
@ -138,7 +160,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
} }
/** /**
* nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的
* *
@ -214,7 +235,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
EnvConstants.USERNAME, getUser(), EnvConstants.USERNAME, getUser(),
EnvConstants.PWD, getPassword()); EnvConstants.PWD, getPassword());
String res = HttpToolbox.post(url, params, headers); String res = HttpToolbox.post(url, params, headers);
if (res == null) { if (Strings.isNullOrEmpty(res)) {
if (needMessage) { if (needMessage) {
JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed"));
} }
@ -237,7 +258,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
return false; return false;
} else { } else {
if (needMessage) { if (needMessage) {
JOptionPane.showMessageDialog(component, Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed"));
} else { } else {
FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"}));
} }
@ -818,7 +839,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
} }
/** /**
* 获取当前env的build文件路径 * 获取当前env的build文件路径
*/ */

30
designer-base/src/com/fr/env/SignIn.java vendored

@ -1,13 +1,10 @@
package com.fr.env; package com.fr.env;
import com.fr.base.FRContext;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext; import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent; import com.fr.core.env.EnvEvent;
import com.fr.core.env.resource.EnvConfigUtils; import com.fr.design.mainframe.DesignerContext;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.dav.LocalEnv;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
@ -16,8 +13,7 @@ import com.fr.event.Null;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.UIManager;
public class SignIn { public class SignIn {
@ -26,36 +22,22 @@ public class SignIn {
EventDispatcher.listen(EnvEvent.CONNECTION_ERROR, new Listener<Null>() { EventDispatcher.listen(EnvEvent.CONNECTION_ERROR, new Listener<Null>() {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, Null param) {
if (JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Remote_Connect2Server_Again"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION) JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed"));
== JOptionPane.OK_OPTION) {
try {
EnvContext.signIn(EnvContext.currentEnv());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
} }
}); });
} }
/** /**
* 注册入环境 * 注册入环境
*
* @param selectedEnv 选择的环境 * @param selectedEnv 选择的环境
* @throws Exception 异常 * @throws Exception 异常
*/ */
public static void signIn(EnvConfig selectedEnv) throws Exception { public static void signIn(EnvConfig selectedEnv) throws Exception {
if (EnvContext.currentEnv() != null && !ComparatorUtils.equals(EnvContext.currentEnv(), selectedEnv)) { if (EnvContext.currentEnv() != null && !ComparatorUtils.equals(EnvContext.currentEnv(), selectedEnv)) {
EnvContext.signOut(); EnvContext.signOut();
} }
EnvContext.signIn(selectedEnv); DesignUtils.switchToEnv(selectedEnv);
DesignUtils.switchToEnv(trans(selectedEnv));
}
private static com.fr.base.Env trans(EnvConfig env) {
if (env instanceof RemoteEnvConfig) {
return new RemoteEnv(env.getPath(), EnvConfigUtils.getUsername(env), EnvConfigUtils.getPassword(env));
} else {
return new LocalEnv();
}
} }
} }

2
designer-base/src/com/fr/start/BBSGuestPaneProvider.java

@ -10,6 +10,6 @@ package com.fr.start;
*/ */
public interface BBSGuestPaneProvider { public interface BBSGuestPaneProvider {
public static final String XML_TAG = "BBSGuestPane"; String XML_TAG = "BBSGuestPane";
} }

7
designer-base/src/com/fr/start/BaseDesigner.java

@ -13,11 +13,14 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.event.EventDispatcher;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleEvent;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import java.awt.*; import java.awt.*;
@ -39,7 +42,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
} }
private void init(String[] args) { private void init(String[] args) {
//初始化
EventDispatcher.fire(ModuleEvent.MajorModuleStarting, InterProviderFactory.getProvider().getLocText("FR-Designer_Initializing"));
// 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到
DesignUtils.initLookAndFeel(); DesignUtils.initLookAndFeel();
@ -93,6 +97,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
+ DesignerEnvManager.getEnvManager().getLastOpenFile()); + DesignerEnvManager.getEnvManager().getLastOpenFile());
} }
isException = openFile(df, isException, file); isException = openFile(df, isException, file);
df.fireDesignerOpened();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (!isException) { if (!isException) {

154
designer-base/src/com/fr/start/StartServer.java → designer-base/src/com/fr/start/ServerStarter.java

@ -16,57 +16,43 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.start.server.TomcatHost; import com.fr.start.server.FineEmbedServer;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JOptionPane; import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Font;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
public class StartServer { public class ServerStarter {
public static boolean NEED_LOAD_ENV = true;
// 原先的tomcatHost放在类TomcatHost里面,很不方便操作,而且因为存在多个进程的原因,
// 原先的getInstance()方法无多大意义
private static TomcatHost tomcatHost = null;
private static Object lock = new Object();
static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() {
currentEnvChanged();
}
});
}
/** /**
* 预览Demo * 预览Demo
* 找默认工作目录不应该按照名字去找而应该按照安装路径因为默认工作目录的名字可能会改变 * 找默认工作目录不应该按照名字去找而应该按照安装路径因为默认工作目录的名字可能会改变
*/ */
public static void browserDemoURL() { public static void browserDemoURL() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { if (FRContext.getCurrentEnv() instanceof RemoteEnv) {
browser(FRContext.getCurrentEnv().getPath()); browser(FRContext.getCurrentEnv().getPath());
return; return;
} }
if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName());
return; return;
} }
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
if (!envManager.isCurrentEnvDefault()) { if (!envManager.isCurrentEnvDefault()) {
InformationPane inf = new InformationPane(envManager.getDefaultEnvName()); InformationPane inf = new InformationPane(envManager.getDefaultEnvName());
inf.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { inf.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
try { try {
SignIn.signIn(DesignerEnvManager.getEnvManager().getDefaultEnv()); SignIn.signIn(DesignerEnvManager.getEnvManager().getDefaultEnv());
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
@ -76,99 +62,43 @@ public class StartServer {
} }
initDemoServerAndBrowser(); initDemoServerAndBrowser();
} }
}).setVisible(true); }).setVisible(true);
} else { } else {
initDemoServerAndBrowser(); initDemoServerAndBrowser();
} }
} }
private static void initDemoServerAndBrowser() { private static void initDemoServerAndBrowser() {
synchronized (lock) {
if (tomcatHost != null) {
if (!tomcatHost.isDemoAppLoaded()) {
tomcatHost.exit();
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartInstallHomeWebApp();
}
} else {
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartInstallHomeWebApp();
}
}
try { try {
if (!tomcatHost.isStarted()) { FineEmbedServer.getInstance().start();
tomcatHost.start();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} finally { } finally {
//先访问Demo, 后访问报表, 不需要重置服务器. //先访问Demo, 后访问报表, 不需要重置服务器.
NEED_LOAD_ENV = false; browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName());
browser("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName());
}
}
public static void start() {
try {
synchronized (lock) {
if (tomcatHost != null) {
if (NEED_LOAD_ENV) {
tomcatHost.exit();
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartLocalEnvHomeWebApp();
}
} else {
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartLocalEnvHomeWebApp();
}
if (!tomcatHost.isStarted()) {
tomcatHost.start();
}
}
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} finally {
NEED_LOAD_ENV = false;
} }
} }
/** /**
* 本地环境浏览url * 本地环境浏览url
* *
* @param url 指定路径 * @param url 指定路径
*/ */
public static void browserURLWithLocalEnv(String url) { public static void browserURLWithLocalEnv(String url) {
start();
FineEmbedServer.getInstance().start();
browser(url); browser(url);
} }
public static TomcatHost getInstance() {
// august: 正确的逻辑能保证jettyHost不为null,不然就有bug,不允许这儿加是否等于null判断
return tomcatHost;
}
/**
* 运行环境改变事件
*/
public static void currentEnvChanged() {
if (!NEED_LOAD_ENV) {
NEED_LOAD_ENV = true;
}
}
private static void browser(String uri) { private static void browser(String uri) {
if (StringUtils.isEmpty(uri)) { if (StringUtils.isEmpty(uri)) {
FRContext.getLogger().info("The URL is empty!"); FRContext.getLogger().info("The URL is empty!");
return; return;
} }
try { try {
Desktop.getDesktop().browse(new URI(uri)); Desktop.getDesktop().browse(new URI(uri));
} catch (IOException e) { } catch (IOException e) {
startBrowserFromCommand(uri, e); startBrowserFromCommand(uri, e);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
@ -178,8 +108,9 @@ public class StartServer {
FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + uri); FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + uri);
} }
} }
private static void startBrowserFromCommand(String uri, IOException e) { private static void startBrowserFromCommand(String uri, IOException e) {
if (OperatingSystem.isWindows()) { if (OperatingSystem.isWindows()) {
try { try {
// win10 内存用到到80%左右的时候, Desktop.browser经常提示"存储空间不足, 无法处理改命令", 用rundll32可以打开. // win10 内存用到到80%左右的时候, Desktop.browser经常提示"存储空间不足, 无法处理改命令", 用rundll32可以打开.
@ -192,30 +123,40 @@ public class StartServer {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
public static boolean isStarted() {
return FineEmbedServer.getInstance().isRunning();
}
private static class InformationPane extends BasicPane { private static class InformationPane extends BasicPane {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final int FREE_STYLE_TOP = 15; private static final int FREE_STYLE_TOP = 15;
private static final int FREE_STYLE_OTHER = 5; private static final int FREE_STYLE_OTHER = 5;
public InformationPane(String message) { InformationPane(String message) {
init(message); init(message);
} }
private void init(String message) { private void init(String message) {
this.setLayout(new BorderLayout(10, 10)); this.setLayout(new BorderLayout(10, 10));
this.setBorder(BorderFactory.createEmptyBorder(FREE_STYLE_TOP, FREE_STYLE_OTHER, FREE_STYLE_OTHER, FREE_STYLE_OTHER)); this.setBorder(BorderFactory.createEmptyBorder(FREE_STYLE_TOP, FREE_STYLE_OTHER, FREE_STYLE_OTHER, FREE_STYLE_OTHER));
String text; String text;
if (!ComparatorUtils.equals(message, Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}))) { if (!ComparatorUtils.equals(message, Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}))) {
text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) text = Inter.getLocText("FR-Designer_Open") +
.append(ProductConstants.APP_NAME) ProductConstants.APP_NAME +
.append(Inter.getLocText("FR-Designer_Utils-OpenDemoEnv")) Inter.getLocText("FR-Designer_Utils-OpenDemoEnv") +
.append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); message + Inter.getLocText("FR-Designer_Utils-switch");
} else { } else {
text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) text = Inter.getLocText("FR-Designer_Open") +
.append(ProductConstants.APP_NAME) ProductConstants.APP_NAME +
.append(Inter.getLocText("FR-Designer_Utils-NewDemoEnv")) Inter.getLocText("FR-Designer_Utils-NewDemoEnv") +
.append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); message + Inter.getLocText("FR-Designer_Utils-switch");
} }
UITextArea a = new UITextArea(text); UITextArea a = new UITextArea(text);
a.setFont(new Font("Dialog", Font.PLAIN, 12)); a.setFont(new Font("Dialog", Font.PLAIN, 12));
@ -224,12 +165,13 @@ public class StartServer {
a.setLineWrap(true); a.setLineWrap(true);
this.add(a); this.add(a);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Tooltips"); return Inter.getLocText("FR-Designer_Tooltips");
} }
} }
} }

34
designer-base/src/com/fr/start/SplashStrategy.java

@ -0,0 +1,34 @@
package com.fr.start;
/**
* 启动动画策略接口
*
* @author vito
* @date 2018/6/1
*/
public interface SplashStrategy {
/**
* 显示启动动画窗口
*/
void show();
/**
* 隐藏启动动画窗口
*/
void hide();
/**
* 设置模块加载信息
*
* @param text 更新的文字
*/
void updateModuleLog(String text);
/**
* 设置感谢文字
*
* @param text 更新的文字
*/
void updateThanksLog(String text);
}

56
designer-base/src/com/fr/start/TomcatFRHost.java

@ -1,56 +0,0 @@
package com.fr.start;
import java.io.File;
import javax.servlet.ServletException;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.startup.Tomcat;
public class TomcatFRHost {
private static Tomcat tomcat;
public static Tomcat getTomcat() {
return tomcat;
}
private static StandardServer server;
private static AprLifecycleListener listener;
public static void main(String[] args) throws Exception {
tomcat = new Tomcat();
// 主机名,或ip
// tomcat.setHostname("localhost");
// 设置端口,80为默认端口
tomcat.setPort(8071);
// tomcat用于存储自身的信息,可以随意指定,最好包含在项目目录下
tomcat.setBaseDir(".");
// 建立server参照tomcat文件结构
server = (StandardServer) tomcat.getServer();
listener = new AprLifecycleListener();
server.addLifecycleListener(listener);
// 将appBase设为本项目所在目录
//tomcat.getHost().setAppBase(".");
tomcat.getHost().setAppBase(
System.getProperty("user.dir") + File.separator + ".");
// 第二个参数对应docBase为web应用路径,目录下应有WEB-INF,WEB-INF下要有web.xml
// 启动tomcat
try {
tomcat.start();
Context ct1 = tomcat.addWebapp("/WebReport", "/Users/momeak/Documents/Working/develop/others/tomcatsrc/WebReport");
} catch (LifecycleException e) {
e.printStackTrace();
} catch (ServletException e) {
e.printStackTrace();
}
// Context ct1 = tomcat.addWebapp("/examples", "/Users/momeak/Documents/Working/develop/others/tomcatsrc/examples");
// Context ct = tomcat.addWebapp("", "/Users/momeak/Documents/Working/develop/others/tomcatsrc/webapps/ROOT");
// tomcat.getServer().await();
System.out.println("启动成功");
}
}

15
designer-base/src/com/fr/start/server/EmbedServerEvent.java

@ -0,0 +1,15 @@
package com.fr.start.server;
import com.fr.event.Event;
import com.fr.event.Null;
/**
* Created by juhaoyu on 2018/6/5.
* 内置服务器事件
*/
public enum EmbedServerEvent implements Event<Null> {
BeforeStart,
AfterStart,
BeforeStop,
AfterStop
}

133
designer-base/src/com/fr/start/server/FRTomcat.java

@ -1,133 +0,0 @@
package com.fr.start.server;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import org.apache.catalina.Context;
import org.apache.catalina.Host;
import org.apache.catalina.core.ContainerBase;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.startup.ContextConfig;
import org.apache.catalina.startup.Tomcat;
public class FRTomcat extends Tomcat{
private final Map<String, Logger> frpinnedLoggers = new HashMap<String, Logger>();
private boolean frsilent = false;
public Context addWebapp(String contextPath, String docBase) throws ServletException {
silence(host, contextPath);
Context ctx = createContext(host, contextPath);
if (ctx instanceof StandardContext) {
((StandardContext)ctx).setDelegate(true);
}
ctx.setPath(contextPath);
ctx.setDocBase(docBase);
ctx.addLifecycleListener(new DefaultWebXmlListener());
ctx.setConfigFile(getWebappConfigFile(docBase, contextPath));
ContextConfig ctxCfg = new ContextConfig();
ctx.addLifecycleListener(ctxCfg);
ctxCfg.setDefaultWebXml(noDefaultWebXmlPath());
if (host == null) {
getHost().addChild(ctx);
} else {
host.addChild(ctx);
}
return ctx;
}
private void silence(Host host, String contextPath) {
String loggerName = getLoggerName(host, contextPath);
Logger logger = Logger.getLogger(loggerName);
frpinnedLoggers.put(loggerName, logger);
if (frsilent) {
logger.setLevel(Level.WARNING);
} else {
logger.setLevel(Level.INFO);
}
}
private String getLoggerName(Host host, String contextName) {
if (host == null) {
host = getHost();
}
StringBuilder loggerName = new StringBuilder();
loggerName.append(ContainerBase.class.getName());
loggerName.append(".[");
// Engine name
loggerName.append(host.getParent().getName());
loggerName.append("].[");
// Host name
loggerName.append(host.getName());
loggerName.append("].[");
// Context name
if (contextName == null || contextName.equals("")) {
loggerName.append("/");
} else if (contextName.startsWith("##")) {
loggerName.append("/");
loggerName.append(contextName);
}
loggerName.append(']');
return loggerName.toString();
}
private Context createContext(Host host, String url) {
String contextClass = StandardContext.class.getName();
if (host == null) {
host = this.getHost();
}
if (host instanceof StandardHost) {
contextClass = ((StandardHost) host).getContextClass();
}
try {
return (Context) Class.forName(contextClass).getConstructor()
.newInstance();
} catch (InstantiationException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
} catch (SecurityException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(
"Can't instantiate context-class " + contextClass
+ " for host " + host + " and url "
+ url, e);
}
}
}

134
designer-base/src/com/fr/start/server/FineEmbedServer.java

@ -0,0 +1,134 @@
package com.fr.start.server;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleRole;
import com.fr.startup.FineWebApplicationInitializer;
import com.fr.third.springframework.web.SpringServletContainerInitializer;
import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.loader.VirtualWebappLoader;
import org.apache.catalina.startup.Tomcat;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
/**
* Created by juhaoyu on 2018/6/5.
*/
public class FineEmbedServer {
private static final FineEmbedServer INSTANCE = new FineEmbedServer();
private Tomcat tomcat;
private volatile boolean isRunning = false;
public static FineEmbedServer getInstance() {
return INSTANCE;
}
private FineEmbedServer() {}
public synchronized void start() {
if (isRunning) {
return;
}
EventDispatcher.fire(EmbedServerEvent.BeforeStart);
try {
//初始化tomcat
initTomcat();
tomcat.start();
} catch (LifecycleException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
isRunning = true;
EventDispatcher.fire(EmbedServerEvent.AfterStart);
}
public synchronized void stop() {
if (!isRunning) {
return;
}
EventDispatcher.fire(EmbedServerEvent.BeforeStop);
try {
stopSpring();
stopServerActivator();
stopTomcat();
} catch (LifecycleException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
isRunning = false;
EventDispatcher.fire(EmbedServerEvent.AfterStop);
}
public boolean isRunning() {
return isRunning;
}
private void initTomcat() {
tomcat = new Tomcat();
tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort());
String docBase = new File(FRContext.getCurrentEnv().getPath()).getParent();
String appName = "/" + FRContext.getCurrentEnv().getAppName();
Context context = tomcat.addContext(appName, docBase);
tomcat.addServlet(appName, "default", "org.apache.catalina.servlets.DefaultServlet");
//覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader());
//直接指定initializer,tomcat就不用再扫描一遍了
SpringServletContainerInitializer initializer = new SpringServletContainerInitializer();
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(FineWebApplicationInitializer.class);
context.addServletContainerInitializer(initializer, classes);
}
private void stopServerActivator() {
ModuleRole.ServerRoot.stop();
}
private void stopSpring() {
AnnotationConfigWebApplicationContext context = ModuleRole.ServerRoot.getSingleton(AnnotationConfigWebApplicationContext.class);
if (context != null) {
context.stop();
context.destroy();
}
}
private void stopTomcat() throws LifecycleException {
tomcat.stop();
tomcat.destroy();
}
/**
* Created by juhaoyu on 2018/6/5.
* 自定义的tomcat loader主要用于防止内置服务器再加载一遍class
*/
private static class FRTomcatLoader extends VirtualWebappLoader {
@Override
public ClassLoader getClassLoader() {
return this.getClass().getClassLoader();
}
}
}

62
designer-base/src/com/fr/start/server/MultiOutputStream.java

@ -1,62 +0,0 @@
package com.fr.start.server;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
/**
* p: 这是为了将一个OutputStream输出多个OutputStream
*/
public class MultiOutputStream extends OutputStream {
private List outList = new ArrayList();
public MultiOutputStream() {
}
public void addOutputStream(OutputStream output) {
this.outList.add(output);
}
public void removeOutputStream(OutputStream output) {
this.outList.remove(output);
}
public int getOutputStreamCount() {
return this.outList.size();
}
public OutputStream getOutputStream(int index) {
return (OutputStream) this.outList.get(index);
}
public void write(int b) throws IOException {
for(int i = 0; i < outList.size(); i++) {
((OutputStream)outList.get(i)).write(b);
}
}
public void write(byte buff[]) throws IOException {
for(int i = 0; i < outList.size(); i++) {
((OutputStream)outList.get(i)).write(buff);
}
}
public void write(byte buff[], int off, int len) throws IOException {
for(int i = 0; i < outList.size(); i++) {
((OutputStream)outList.get(i)).write(buff, off, len);
}
}
public void flush() throws IOException {
for(int i = 0; i < outList.size(); i++) {
((OutputStream)outList.get(i)).flush();
}
}
public void close() throws IOException {
for(int i = 0; i < outList.size(); i++) {
((OutputStream)outList.get(i)).close();
}
}
}

76
designer-base/src/com/fr/start/server/ServerManageFrame.java

@ -1,27 +1,20 @@
package com.fr.start.server; package com.fr.start.server;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import com.fr.base.FRContext;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.start.StartServer;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.start.ServerStarter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/** /**
* 内置Tomcat服务器管理界面 * 内置Tomcat服务器管理界面
@ -29,11 +22,11 @@ import com.fr.design.utils.gui.GUICoreUtils;
public class ServerManageFrame extends JFrame { public class ServerManageFrame extends JFrame {
// 由于实际情况,只需要一个当前对象的Instance. // 由于实际情况,只需要一个当前对象的Instance.
private static ServerManageFrame serverManageFrame = null; private static ServerManageFrame serverManageFrame = null;
private TomcatHost hostTomcatServer;
public static ServerManageFrame getServerManageFrame(TomcatHost hostTomcatServer) { static ServerManageFrame getServerManageFrame() {
if(serverManageFrame == null) {
serverManageFrame = new ServerManageFrame(hostTomcatServer); if (serverManageFrame == null) {
serverManageFrame = new ServerManageFrame();
} }
//p:每次启动之前都需要检查按钮的Enabled属性. //p:每次启动之前都需要检查按钮的Enabled属性.
@ -49,8 +42,7 @@ public class ServerManageFrame extends JFrame {
private JPanel startPane; private JPanel startPane;
private JPanel stopPane; private JPanel stopPane;
private ServerManageFrame(TomcatHost hostTomcatServer) { private ServerManageFrame() {
this.hostTomcatServer = hostTomcatServer;
DesignUtils.initLookAndFeel(); DesignUtils.initLookAndFeel();
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png")); this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png"));
@ -82,12 +74,8 @@ public class ServerManageFrame extends JFrame {
startPane.add(new UILabel(Inter.getLocText("Server-Start"))); startPane.add(new UILabel(Inter.getLocText("Server-Start")));
startButton.addActionListener(new ActionListener() { startButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
TomcatHost tomcatServer = StartServer.getInstance();
try { try {
if(!tomcatServer.isStarted()) { FineEmbedServer.getInstance().start();
tomcatServer.start();
tomcatServer.addAndStartLocalEnvHomeWebApp();
}
checkButtonEnabled(); checkButtonEnabled();
} catch(Exception exp) { } catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage()); FRContext.getLogger().error(exp.getMessage());
@ -103,11 +91,8 @@ public class ServerManageFrame extends JFrame {
stopPane.add(new UILabel(Inter.getLocText("Server-Stop"))); stopPane.add(new UILabel(Inter.getLocText("Server-Stop")));
stopButton.addActionListener(new ActionListener() { stopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
TomcatHost tomcatServer = StartServer.getInstance();
try { try {
if(tomcatServer.isStarted()) { FineEmbedServer.getInstance().stop();
tomcatServer.stop();
}
checkButtonEnabled(); checkButtonEnabled();
} catch(Exception exp) { } catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage()); FRContext.getLogger().error(exp.getMessage());
@ -125,24 +110,21 @@ public class ServerManageFrame extends JFrame {
infoPane.add(logPathTextField, BorderLayout.CENTER); infoPane.add(logPathTextField, BorderLayout.CENTER);
logPathTextField.setEditable(false); logPathTextField.setEditable(false);
// logfile
logPathTextField.setText(hostTomcatServer.getOutLogFile().getPath());
UIButton openButton = new UIButton(); UIButton openButton = new UIButton();
infoPane.add(openButton, BorderLayout.EAST); infoPane.add(openButton, BorderLayout.EAST);
openButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/server/view.png")); openButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/server/view.png"));
openButton.setToolTipText(Inter.getLocText("Open")); openButton.setToolTipText(Inter.getLocText("Open"));
openButton.addActionListener(new ActionListener() { // openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { // public void actionPerformed(ActionEvent evt) {
//
Desktop desktop = Desktop.getDesktop(); // Desktop desktop = Desktop.getDesktop();
try { // try {
desktop.open(ServerManageFrame.this.hostTomcatServer.getOutLogFile()); // desktop.open();
} catch(Exception exp) { // } catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage()); // FRContext.getLogger().error(exp.getMessage());
} // }
} // }
}); // });
this.setSize(420, 160); this.setSize(420, 160);
this.setTitle(Inter.getLocText("Server-Embedded_Server")); this.setTitle(Inter.getLocText("Server-Embedded_Server"));
@ -154,8 +136,8 @@ public class ServerManageFrame extends JFrame {
* @throws Exception 异常 * @throws Exception 异常
*/ */
public void checkButtonEnabled() throws Exception { public void checkButtonEnabled() throws Exception {
TomcatHost tomcatServer = StartServer.getInstance();
if(tomcatServer.isStarted()) { if (ServerStarter.isStarted()) {
GUICoreUtils.setEnabled(startPane, false); GUICoreUtils.setEnabled(startPane, false);
GUICoreUtils.setEnabled(stopPane, true); GUICoreUtils.setEnabled(stopPane, true);
} else { } else {

198
designer-base/src/com/fr/start/server/ServerTray.java

@ -1,82 +1,76 @@
package com.fr.start.server; package com.fr.start.server;
import java.awt.AWTException; import com.fr.base.BaseUtils;
import java.awt.Image; import com.fr.base.FRContext;
import java.awt.MenuItem; import com.fr.event.Event;
import java.awt.PopupMenu; import com.fr.event.EventDispatcher;
import java.awt.SystemTray; import com.fr.event.ListenerAdaptor;
import java.awt.TrayIcon; import com.fr.general.Inter;
import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.general.Inter;
import com.fr.start.StartServer;
/** /**
* Create server tray. * Create server tray.
*/ */
public class ServerTray { public class ServerTray {
public static boolean JVM_EXIT_ON_TRAY_EXIT = false;
private static ServerTray INSTANCE;
private MenuItem manangeMenu, startMenu, stopMenu, exitMenu;
private Image trayStartedImage = BaseUtils.readImage( private MenuItem startMenu;
"/com/fr/base/images/oem/trayStarted.png");
private Image trayStoppedImage = BaseUtils.readImage( private MenuItem stopMenu;
"/com/fr/base/images/oem/trayStopped.png");
private Image trayStartedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png");
private Image trayStoppedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStopped.png");
private ServerManageFrame serverManageFrame; private ServerManageFrame serverManageFrame;
private TrayIcon trayIcon; private TrayIcon trayIcon;
private TomcatHost hostTomcatServer;
private ServerTray() {
public ServerTray(TomcatHost hostTomcatServer) { listen();
//p:首先构建右键菜单
this.hostTomcatServer = hostTomcatServer; PopupMenu popup = new PopupMenu();
MenuItem manangeMenu = new MenuItem(Inter.getLocText("Server-Open_Service_Manager"));
//p:首先构建右键菜单
PopupMenu popup = new PopupMenu();
manangeMenu = new MenuItem(Inter.getLocText("Server-Open_Service_Manager"));
manangeMenu.addActionListener(new ActionListener() { manangeMenu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
serverManageFrame = ServerManageFrame.getServerManageFrame(ServerTray.this.hostTomcatServer);
if(!serverManageFrame.isVisible()) { serverManageFrame = ServerManageFrame.getServerManageFrame();
serverManageFrame.setVisible(true); if (!serverManageFrame.isVisible()) {
} serverManageFrame.setVisible(true);
serverManageFrame.toFront();//p:到第一个. }
serverManageFrame.toFront();//p:到第一个.
} }
}); });
startMenu = new MenuItem(Inter.getLocText("FR-Server_Embedded_Server_Start")); startMenu = new MenuItem(Inter.getLocText("FR-Server_Embedded_Server_Start"));
stopMenu = new MenuItem(Inter.getLocText("FR-Server_Embedded_Server_Stop")); stopMenu = new MenuItem(Inter.getLocText("FR-Server_Embedded_Server_Stop"));
exitMenu = new MenuItem(Inter.getLocText("Exit")); MenuItem exitMenu = new MenuItem(Inter.getLocText("Exit"));
//创建打开监听器 //创建打开监听器
ActionListener startListener = new ActionListener() { ActionListener startListener = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
TomcatHost tomcatServer = StartServer.getInstance();
try { try {
if(!tomcatServer.isStarted()) { FineEmbedServer.getInstance().start();
tomcatServer.start(); } catch (Exception exp) {
tomcatServer.addAndStartLocalEnvHomeWebApp();//暂停后再打开Tomcat,需要addApp FRContext.getLogger().error(exp.getMessage(), exp);
}
} catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage(), exp);
} }
} }
}; };
ActionListener stopListener = new ActionListener() { ActionListener stopListener = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
TomcatHost tomcatServer = StartServer.getInstance();
try { try {
if(tomcatServer.isStarted()) { FineEmbedServer.getInstance().stop();
tomcatServer.stop(); } catch (Throwable exp) {
} FRContext.getLogger().error(exp.getMessage(), exp);
} catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage(), exp);
} }
} }
}; };
@ -105,18 +99,18 @@ public class ServerTray {
if(e.getClickCount() < 2) { if(e.getClickCount() < 2) {
return; return;
} }
ServerManageFrame serverManageFrame = ServerManageFrame.getServerManageFrame(ServerTray.this.hostTomcatServer); ServerManageFrame serverManageFrame = ServerManageFrame.getServerManageFrame();
if(!serverManageFrame.isVisible()) { if (!serverManageFrame.isVisible()) {
serverManageFrame.setVisible(true); serverManageFrame.setVisible(true);
} }
serverManageFrame.toFront();//p:到第一个. serverManageFrame.toFront();//p:到第一个.
} }
}); });
TrayIcon[] ti = SystemTray.getSystemTray().getTrayIcons(); TrayIcon[] icons = SystemTray.getSystemTray().getTrayIcons();
for(int i = 0;i <ti.length; i++){ for (TrayIcon icon : icons) {
SystemTray.getSystemTray().remove(ti[i]); SystemTray.getSystemTray().remove(icon);
} }
try { try {
@ -124,66 +118,33 @@ public class ServerTray {
} catch (AWTException e) { } catch (AWTException e) {
System.err.println("Can not create the System Tray:" + e); System.err.println("Can not create the System Tray:" + e);
} }
//p:先check checkPopupMenuItemEnabled();
checkPopupMenuItemEnabled(this.hostTomcatServer);
// TODOJ
this.hostTomcatServer.addListener(new MyTomcatListner());
try {
if (!this.hostTomcatServer.isStarted()) {
this.hostTomcatServer.start();
}
} catch (Exception e){
FRContext.getLogger().error(e.getMessage(), e);
}
} }
private void exit() { private void listen() {
if (hostTomcatServer != null) {
try { ListenerAdaptor listenerAdaptor = new ListenerAdaptor() {
if(hostTomcatServer.isStarted()) {
hostTomcatServer.exit(); @Override
} protected void on(Event event) {
} catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage(), exp); checkPopupMenuItemEnabled();
} }
};
hostTomcatServer = null; EventDispatcher.listen(EmbedServerEvent.AfterStart, listenerAdaptor);
} EventDispatcher.listen(EmbedServerEvent.AfterStop, listenerAdaptor);
}
private void exit() {
FineEmbedServer.getInstance().stop();
SystemTray.getSystemTray().remove(trayIcon); SystemTray.getSystemTray().remove(trayIcon);
if (JVM_EXIT_ON_TRAY_EXIT) {
System.exit(0);
}
} }
class MyTomcatListner implements TomcatServerListener { private void checkPopupMenuItemEnabled() {
/**
* Started
*/
public void started(TomcatHost tomcatServer) {
checkPopupMenuItemEnabled(tomcatServer);
}
/**
* Stopped
*/
public void stopped(TomcatHost tomcatServer) {
checkPopupMenuItemEnabled(tomcatServer);
}
@Override
public void exited(TomcatHost tomcatServer) {
exit();
}
}
private void checkPopupMenuItemEnabled(TomcatHost tomcatServer) {
try { try {
if(tomcatServer.isStarted()) { if (FineEmbedServer.getInstance().isRunning()) {
startMenu.setEnabled(false); startMenu.setEnabled(false);
stopMenu.setEnabled(true); stopMenu.setEnabled(true);
@ -203,5 +164,10 @@ public class ServerTray {
FRContext.getLogger().error(exp.getMessage(), exp); FRContext.getLogger().error(exp.getMessage(), exp);
} }
} }
public static void init() {
INSTANCE = new ServerTray();
}
} }

280
designer-base/src/com/fr/start/server/TomcatHost.java

@ -1,280 +0,0 @@
package com.fr.start.server;
import com.fr.module.ModuleContext;
import java.awt.SystemTray;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fr.general.GeneralContext;
import com.fr.stable.ProductConstants;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Server;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.StandardServer;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager;
import com.fr.general.Inter;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.start.StartServer;
public class TomcatHost {
private static FRTomcat tomcat;
private StandardServer server;
private AprLifecycleListener listener;
// private Server server;
private MultiOutputStream multiOutputStream = null;
private File outLogFile = null;
private int currentPort = -1;
// 内置服务器一个端口下面可以有多个应用,但是content不能重名
private Map<String, Context> webAppsMap = new HashMap<String, Context>();
private List<TomcatServerListener> listenerList = new ArrayList<TomcatServerListener>();
private boolean isDemoAppLoaded = false;
public TomcatHost(int port) {
this.currentPort = port;
initServer();
initLogFileAndOutputStream();
// TODO: 将HostTomcatServer放到ServerTray中去
tryStartServerTray();
}
public static FRTomcat getTomcat() {
return tomcat;
}
private void initServer() {
try {
//直接用自定义的,不用server.xml
this.tomcat = new FRTomcat();
this.tomcat.setPort(this.currentPort);
this.tomcat.setBaseDir(StableUtils.getInstallHome());
this.server = (StandardServer) tomcat.getServer();
this.listener = new AprLifecycleListener();
this.server.addLifecycleListener(listener);
this.tomcat.getHost().setAppBase(StableUtils.getInstallHome() + File.separator + ".");
this.tomcat.getConnector().setURIEncoding("UTF-8");
} catch (Exception e) {
//todo 最好加一个用server.xml
FRContext.getLogger().error(e.getMessage(), e);
}
}
private void initLogFileAndOutputStream() {
// log文件放置的位置
File logDir = null;
String installHome = StableUtils.getInstallHome();
if (installHome == null) {// 没有installHome的时候,就放到user.home下面喽
logDir = new File(ProductConstants.getEnvHome() + File.separator + ProjectConstants.LOGS_NAME);
} else {
// james:logs放在安装目录下面
logDir = new File(installHome + File.separator + ProjectConstants.LOGS_NAME + File.separator + "tomcat");
}
StableUtils.mkdirs(logDir);
DateFormat fateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar curCalendar = Calendar.getInstance();
outLogFile = new File(logDir, "tomcat_" + fateFormat.format(curCalendar.getTime()) + ".log");
try {
multiOutputStream = new MultiOutputStream();
multiOutputStream.addOutputStream(new FileOutputStream(outLogFile, true));
multiOutputStream.addOutputStream(System.out);
System.setErr(new PrintStream(multiOutputStream));
System.setOut(new PrintStream(multiOutputStream));
} catch (IOException ioe) {
FRContext.getLogger().error(ioe.getMessage(), ioe);
}
}
private synchronized void addWebApplication(String context, String webappsPath) {
FRContext.getLogger().info("The new Application Path is: \n" + webappsPath + ", it will be added.");
if (webAppsMap.get(context) != null) {
Context webapp = webAppsMap.remove(context);
}
try {
if (!isStarted()) {
start();
}
Context webapp = tomcat.addWebapp(context, webappsPath);
webAppsMap.put(context, webapp);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
private void addAndStartWebApplication(String context, String webAppPath) {
addWebApplication(context, webAppPath);
}
/**
* Get MultiOutputStream.
*/
public MultiOutputStream getMultiOutputStream() {
return this.multiOutputStream;
}
/**
* Get out log file
*/
public File getOutLogFile() {
return this.outLogFile;
}
private Server getServer() {
if (server == null) {
initServer();
}
return server;
}
/**
* Start
*
* @throws Exception
*/
public void start() throws Exception {
tomcat.start();
for (int i = 0; i < listenerList.size(); i++) {
TomcatServerListener listener = TomcatHost.this.getLinstener(i);
listener.started(this);
}
}
/**
* Stop
*
* @throws Exception
*/
public void stop() throws Exception {
tomcat.stop();
for (int i = 0; i < listenerList.size(); i++) {
TomcatServerListener listener = this.getLinstener(i);
listener.stopped(this);
}
StartServer.currentEnvChanged();
server = null;//重置server
}
/**
* Is started
*
* @throws Exception
*/
public boolean isStarted() throws Exception {
return getServer().getState().isAvailable();
}
public void addListener(TomcatServerListener listener) {
this.listenerList.add(listener);
}
public int getLinstenerCount() {
return this.listenerList.size();
}
public TomcatServerListener getLinstener(int index) {
if (index < 0 || index >= this.getLinstenerCount()) {
return null;
}
return this.listenerList.get(index);
}
public void clearLinsteners() {
this.listenerList.clear();
}
/**
* 尝试启动系统托盘
*/
private void tryStartServerTray() {
if (SystemTray.isSupported()) {
new ServerTray(this);
} else {
FRContext.getLogger().error("Do not support the SystemTray!");
}
}
public void exit() {
try {
getServer().stop();
} catch (LifecycleException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
for (int i = 0; i < listenerList.size(); i++) {
TomcatServerListener listener = this.getLinstener(i);
listener.exited(this);
}
try {
getServer().destroy();
} catch (LifecycleException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
StartServer.currentEnvChanged();
}
public int getCurrentPort() {
return currentPort;
}
/**
* 安装目录下的默认的WebReport这个只执行一次,除了预览demo其他的不要调用这个方法
*/
public void addAndStartInstallHomeWebApp() {
if (!isDemoAppLoaded) {
String installHome = StableUtils.getInstallHome();
String webApplication = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME});
if (new File(webApplication).isDirectory()) {
addAndStartWebApplication("/" + ProjectConstants.WEBAPP_NAME, webApplication);
}
}
isDemoAppLoaded = true;
}
/**
* 加载Env下的报表运行环境
*/
public void addAndStartLocalEnvHomeWebApp() {
String name = DesignerEnvManager.getEnvManager().getCurEnvName();
if (name.equals(Inter.getLocText("Default"))) {
isDemoAppLoaded = true;
}
Env env = FRContext.getCurrentEnv();
if (env instanceof LocalEnv) {
String webApplication = new File(env.getPath()).getParent();
FRContext.getLogger().info(Inter.getLocText("INFO-Reset_Webapp") + ":" + webApplication);
addAndStartWebApplication("/" + GeneralContext.getCurrentAppNameOfEnv(), webApplication);
}
}
public boolean isDemoAppLoaded() {
return isDemoAppLoaded;
}
}

18
designer-base/src/com/fr/start/server/TomcatServerListener.java

@ -1,18 +0,0 @@
package com.fr.start.server;
public interface TomcatServerListener {
/**
* Started
*/
public void started(TomcatHost tomcatServer);
/**
* Stopped
*/
public void stopped(TomcatHost tomcatServer);
/**
* Exited
*/
public void exited(TomcatHost tomcatServer);
}

6
designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java

@ -8,7 +8,7 @@ import com.fr.design.actions.UpdateAction;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.start.StartServer; import com.fr.start.ServerStarter;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -23,11 +23,11 @@ public class ChartMapEditorAction extends UpdateAction {
} }
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
int port = DesignerEnvManager.getEnvManager().getJettyServerPort(); int port = DesignerEnvManager.getEnvManager().getEmbedServerPort();
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
String serverlet = ServerConfig.getInstance().getReportServletName(); String serverlet = ServerConfig.getInstance().getReportServletName();
Env env = FRContext.getCurrentEnv(); Env env = FRContext.getCurrentEnv();
StartServer.browserURLWithLocalEnv(env.isLocalEnv() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : env.getPath() + "?op=map"); ServerStarter.browserURLWithLocalEnv(env.isLocalEnv() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : env.getPath() + "?op=map");
} }
} }

3
designer-form/src/com/fr/design/designer/beans/actions/CopyAction.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -18,6 +19,7 @@ public class CopyAction extends FormWidgetEditAction {
this.setMnemonic('C'); this.setMnemonic('C');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER));
setUpdateBehavior(new ComponentEnable());
} }
@Override @Override
@ -28,5 +30,4 @@ public class CopyAction extends FormWidgetEditAction {
} }
return false; return false;
} }
} }

3
designer-form/src/com/fr/design/designer/beans/actions/CutAction.java

@ -6,6 +6,7 @@ import java.awt.event.KeyEvent;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
@ -19,6 +20,7 @@ public class CutAction extends FormWidgetEditAction {
this.setMnemonic('T'); this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
this.setUpdateBehavior(new ComponentEnable());
} }
@Override @Override
@ -29,5 +31,4 @@ public class CutAction extends FormWidgetEditAction {
} }
return editPane.cut(); return editPane.cut();
} }
} }

11
designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java

@ -8,6 +8,7 @@ import java.awt.event.KeyEvent;
import javax.swing.*; import javax.swing.*;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
@ -27,6 +28,13 @@ public class FormDeleteAction extends FormWidgetEditAction {
// Richie:删除菜单图标 // Richie:删除菜单图标
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
this.setUpdateBehavior(new ComponentEnable());
}
@Override
protected String getToolTipText() {
String originText = super.getToolTipText();
return originText.replace(KeyEvent.getKeyText(KeyEvent.VK_BACK_SPACE), KeyEvent.getKeyText(KeyEvent.VK_DELETE));
} }
@Override @Override
@ -48,11 +56,8 @@ public class FormDeleteAction extends FormWidgetEditAction {
if (designer == null) { if (designer == null) {
return false; return false;
} }
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
designer.getSelectionModel().deleteSelection(); designer.getSelectionModel().deleteSelection();
creator.deleteRelatedComponent(creator, designer);
return false; return false;
} }
} }

17
designer-form/src/com/fr/design/designer/beans/actions/FormWidgetEditAction.java

@ -1,23 +1,32 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.designer.beans.actions.behavior.UpdateBehavior;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.general.Inter;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.stable.ReportFunctionProcessor; import com.fr.stable.ReportFunctionProcessor;
import com.fr.stable.fun.FunctionProcessor; import com.fr.stable.fun.FunctionProcessor;
import javax.swing.JButton; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
public abstract class FormWidgetEditAction extends TemplateComponentAction<FormDesigner> { public abstract class FormWidgetEditAction extends TemplateComponentAction<FormDesigner> {
private UpdateBehavior updateBehavior = new UpdateBehavior<FormWidgetEditAction>() {
@Override
public void doUpdate(FormWidgetEditAction action) {
action.setEnabled(true);
}
};
protected FormWidgetEditAction(FormDesigner t) { protected FormWidgetEditAction(FormDesigner t) {
super(t); super(t);
} }
@Override @Override
public void update() { public void update() {
this.setEnabled(true); updateBehavior.doUpdate(this);
} }
@Override @Override
@ -36,4 +45,8 @@ public abstract class FormWidgetEditAction extends TemplateComponentAction<FormD
} }
} }
public void setUpdateBehavior(UpdateBehavior updateBehavior) {
this.updateBehavior = updateBehavior;
}
} }

12
designer-form/src/com/fr/design/designer/beans/actions/MoveDownAction.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.MovableDownEnable;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -28,6 +29,7 @@ public class MoveDownAction extends FormWidgetEditAction {
this.setMnemonic('B'); this.setMnemonic('B');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER));
this.setUpdateBehavior(new MovableDownEnable());
} }
@Override @Override
@ -47,14 +49,4 @@ public class MoveDownAction extends FormWidgetEditAction {
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED);
return true; return true;
} }
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableDown());
}
} }

21
designer-form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.MovableDownEnable;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -27,7 +28,14 @@ public class MoveToBottomAction extends FormWidgetEditAction {
this.setName(Inter.getLocText("FR-Designer_Move_To_Bottom")); this.setName(Inter.getLocText("FR-Designer_Move_To_Bottom"));
this.setMnemonic('K'); this.setMnemonic('K');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_bottom.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)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER + InputEvent.SHIFT_MASK));
this.setUpdateBehavior(new MovableDownEnable());
}
@Override
protected String getToolTipText() {
String originText = super.getToolTipText();
return originText.replace(KeyEvent.getKeyText(KeyEvent.VK_OPEN_BRACKET), "[");
} }
@Override @Override
@ -47,15 +55,4 @@ public class MoveToBottomAction extends FormWidgetEditAction {
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED);
return true; return true;
} }
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableDown());
}
} }

21
designer-form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.MovableUpEnable;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -27,7 +28,14 @@ public class MoveToTopAction extends FormWidgetEditAction {
this.setName(Inter.getLocText("FR-Designer_Move_To_Top")); this.setName(Inter.getLocText("FR-Designer_Move_To_Top"));
this.setMnemonic('T'); this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_top.png")); 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)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER + InputEvent.SHIFT_MASK));
this.setUpdateBehavior(new MovableUpEnable());
}
@Override
protected String getToolTipText() {
String originText = super.getToolTipText();
return originText.replace(KeyEvent.getKeyText(KeyEvent.VK_CLOSE_BRACKET), "]");
} }
@Override @Override
@ -46,15 +54,4 @@ public class MoveToTopAction extends FormWidgetEditAction {
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED);
return true; return true;
} }
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableUp());
}
} }

14
designer-form/src/com/fr/design/designer/beans/actions/MoveUpAction.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.behavior.MovableUpEnable;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -27,6 +28,7 @@ public class MoveUpAction extends FormWidgetEditAction {
this.setMnemonic('F'); this.setMnemonic('F');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER));
this.setUpdateBehavior(new MovableUpEnable());
} }
@Override @Override
@ -43,18 +45,8 @@ public class MoveUpAction extends FormWidgetEditAction {
return false; return false;
} }
container.setComponentZOrder(creator, targetIndex); container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_SELECTED);
return true; return true;
} }
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableUp());
}
} }

20
designer-form/src/com/fr/design/designer/beans/actions/behavior/ComponentEnable.java

@ -0,0 +1,20 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
/**
* 只对控件有效对底层布局form/body无效
* Created by plough on 2018/1/19.
*/
public class ComponentEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(!designer.isRootSelected());
}
}

19
designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableDownEnable.java

@ -0,0 +1,19 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
/**
* Created by plough on 2018/1/19.
*/
public class MovableDownEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(designer.isCurrentComponentMovableDown());
}
}

19
designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableUpEnable.java

@ -0,0 +1,19 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
/**
* Created by plough on 2018/1/19.
*/
public class MovableUpEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(designer.isCurrentComponentMovableUp());
}
}

8
designer-form/src/com/fr/design/designer/beans/actions/behavior/UpdateBehavior.java

@ -0,0 +1,8 @@
package com.fr.design.designer.beans.actions.behavior;
/**
* Created by plough on 2018/1/19.
*/
public interface UpdateBehavior<T> {
public void doUpdate(T t);
}

16
designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java

@ -1,11 +1,5 @@
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
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.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRBorderLayoutPainter; import com.fr.design.designer.beans.painters.FRBorderLayoutPainter;
@ -14,8 +8,13 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.properties.FRBorderLayoutConstraints; import com.fr.design.designer.properties.FRBorderLayoutConstraints;
import com.fr.design.form.layout.FRBorderLayout; import com.fr.design.form.layout.FRBorderLayout;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.general.ComparatorUtils;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
@ -36,9 +35,6 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
* @param creator 组件 * @param creator 组件
*/ */
public void fix(XCreator creator) { public void fix(XCreator creator) {
if(creator.acceptType(XWCardTagLayout.class)){
creator = (XCreator) creator.getParent();
}
FRBorderLayout layout = (FRBorderLayout)container.getFRLayout(); FRBorderLayout layout = (FRBorderLayout)container.getFRLayout();
Object constraints = layout.getConstraints(creator); Object constraints = layout.getConstraints(creator);
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) { if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) {

62
designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java

@ -0,0 +1,62 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.form.layout.FRBorderLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.JOptionPane;
import java.awt.BorderLayout;
import java.awt.Rectangle;
/**
* cardMainBorderLayout适配器
*
* @author kerry
* @date 2019/1/4
*/
public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter {
public FRCardMainBorderLayoutAdapter(XLayoutContainer container) {
super(container);
}
/**
* CardMainBorderLayout的title部分不能超出layout边界
*
* @param creator 组件
*/
@Override
public void fix(XCreator creator) {
if (creator.acceptType(XWCardTagLayout.class)) {
creator = (XCreator) creator.getParent();
}
boolean beyondBounds = calculateBeyondBounds(creator);
if (!beyondBounds) {
super.fix(creator);
}
}
private boolean calculateBeyondBounds(XCreator creator) {
FRBorderLayout layout = (FRBorderLayout) container.getFRLayout();
Object constraints = layout.getConstraints(creator);
Rectangle rectangle = creator.getBounds();
//不能超出控件边界
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH) || ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) {
int containerHeight = container.getHeight();
if (rectangle.height > containerHeight) {
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds"));
return true;
}
} else if (ComparatorUtils.equals(constraints, BorderLayout.EAST) || ComparatorUtils.equals(constraints, BorderLayout.WEST)) {
int containerWidth = container.getWidth();
if (rectangle.width > containerWidth) {
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds"));
return true;
}
}
return false;
}
}

9
designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -811,7 +811,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
if (ry != y) { if (ry != y) {
calculateNoRelatedWhileRightTop(rec, rightComp); calculateNoRelatedWhileRightTop(rec, rightComp);
} else { } else {
calculateNoRelatedWhileRightBott(rec, rightComp); calculateNoRelatedWhileRightBott(rec);
} }
} }
@ -856,8 +856,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height, true); recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height, true);
} }
private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) { private void calculateNoRelatedWhileRightBott(Rectangle bound) {
rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); Component rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width);
if(rcomp == null){
return;
}
int ry = rcomp.getY(); int ry = rcomp.getY();
int rh = rcomp.getHeight(); int rh = rcomp.getHeight();
int rw = rcomp.getWidth(); int rw = rcomp.getWidth();

3
designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -234,7 +234,6 @@ public class SelectionModel {
*/ */
public void deleteSelection() { public void deleteSelection() {
XCreator[] roots = selection.getSelectedCreators(); XCreator[] roots = selection.getSelectedCreators();
if (roots.length > 0) { if (roots.length > 0) {
boolean isInPara = true; // 在参数面板内删除控件 boolean isInPara = true; // 在参数面板内删除控件
for (XCreator creator : roots) { for (XCreator creator : roots) {
@ -245,10 +244,12 @@ public class SelectionModel {
designer.removeParaComponent(); designer.removeParaComponent();
} }
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
creator.deleteRelatedComponent(creator, designer);
creator.removeAll(); creator.removeAll();
// 清除被选中的组件 // 清除被选中的组件
selection.reset(); selection.reset();
} }
setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent());
// 触发事件 // 触发事件
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);

3
designer-form/src/com/fr/design/designer/beans/models/StateModel.java

@ -434,6 +434,9 @@ public class StateModel {
// 拖拽时画依附线用到的painter // 拖拽时画依附线用到的painter
private void setDependLinePainter(MouseEvent e) { private void setDependLinePainter(MouseEvent e) {
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
if (comp == null) {
return;
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator(); XCreator creator = selectionModel.getSelection().getSelectedCreator();
HoverPainter painter = AdapterBus.getContainerPainter(designer, container); HoverPainter painter = AdapterBus.getContainerPainter(designer, container);

14
designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java

@ -5,9 +5,10 @@ package com.fr.design.designer.creator;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import java.awt.*; import java.awt.Component;
import java.awt.Dimension;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.util.ArrayList; import java.util.List;
/** /**
* 一些控件专属的容器如标题容器sclae容器 * 一些控件专属的容器如标题容器sclae容器
@ -27,6 +28,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* @return 属性名 * @return 属性名
* @throws IntrospectionException * @throws IntrospectionException
*/ */
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[0]; return new CRPropertyDescriptor[0];
} }
@ -50,7 +52,8 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* *
* @param path 控件树list * @param path 控件树list
*/ */
public void notShowInComponentTree(ArrayList<Component> path) { @Override
public void notShowInComponentTree(List<Component> path) {
path.remove(path.size() - 1); path.remove(path.size() - 1);
} }
@ -59,6 +62,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* *
* @param name 名称 * @param name 名称
*/ */
@Override
public void resetCreatorName(String name) { public void resetCreatorName(String name) {
super.resetCreatorName(name); super.resetCreatorName(name);
XCreator child = getXCreator(XWScaleLayout.INDEX); XCreator child = getXCreator(XWScaleLayout.INDEX);
@ -70,6 +74,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* 重置组件的可见性 * 重置组件的可见性
* @param visible 可见性 * @param visible 可见性
*/ */
@Override
public void resetVisible(boolean visible){ public void resetVisible(boolean visible){
super.resetVisible(visible); super.resetVisible(visible);
XCreator child = getXCreator(XWScaleLayout.INDEX); XCreator child = getXCreator(XWScaleLayout.INDEX);
@ -80,6 +85,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* *
* @return 组件 * @return 组件
*/ */
@Override
public XCreator getPropertyDescriptorCreator() { public XCreator getPropertyDescriptorCreator() {
return getXCreator(XWScaleLayout.INDEX); return getXCreator(XWScaleLayout.INDEX);
} }
@ -89,6 +95,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isComponentTreeLeaf() { public boolean isComponentTreeLeaf() {
return true; return true;
} }
@ -98,6 +105,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isDedicateContainer() { public boolean isDedicateContainer() {
return true; return true;
} }

35
designer-form/src/com/fr/design/designer/creator/XButton.java

@ -3,20 +3,6 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.beans.IntrospectionException;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.background.GradientBackground; import com.fr.base.background.GradientBackground;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
@ -36,13 +22,26 @@ import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.beans.IntrospectionException;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
*/ */
public class XButton extends XWidgetCreator { public class XButton extends XWidgetCreator {
public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210),GradientBackground.TOP2BOTTOM); public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210), GradientBackground.TOP2BOTTOM);
public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12); public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12);
public final static Color DEFAULTFOREGROUNDCOLOR = Color.BLACK; public final static Color DEFAULTFOREGROUNDCOLOR = Color.BLACK;
private Background bg; private Background bg;
@ -198,10 +197,14 @@ public class XButton extends XWidgetCreator {
protected JComponent initEditor() { protected JComponent initEditor() {
if (editor == null) { if (editor == null) {
editor = new UILabel(); editor = new UILabel();
contentLabel = new UILabel(); contentLabel = initContentLabel();
} }
return editor; return editor;
} }
protected UILabel initContentLabel() {
return new UILabel();
}
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {

35
designer-form/src/com/fr/design/designer/creator/XChartEditor.java

@ -6,6 +6,7 @@ import java.beans.IntrospectionException;
import javax.swing.*; import javax.swing.*;
import com.fr.base.GraphHelper;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
@ -21,6 +22,7 @@ import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
/** /**
@ -32,13 +34,18 @@ import com.fr.stable.core.PropertyChangeAdapter;
*/ */
public class XChartEditor extends XBorderStyleWidgetCreator { public class XChartEditor extends XBorderStyleWidgetCreator {
private static final long serialVersionUID = -7009439442104836657L; private static final long serialVersionUID = -7009439442104836657L;
private static final int BORDER_WIDTH = 2;
//具体来说是DesignerEditor<SimpleChartComponent> //具体来说是DesignerEditor<SimpleChartComponent>
private DesignerEditor<JComponent> designerEditor; private DesignerEditor<JComponent> designerEditor;
// private DesignerEditor<SimpleChartComponent> designerEditor; // private DesignerEditor<SimpleChartComponent> designerEditor;
//marro:无奈的属性,暂时想不出好办法 //marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false; private boolean isRefreshing = false;
private boolean isHovering = false;
private boolean isEditing = false; private boolean isEditing = false;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249);
private JPanel coverPanel; private JPanel coverPanel;
public XChartEditor(BaseChartEditor editor) { public XChartEditor(BaseChartEditor editor) {
@ -180,12 +187,32 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return bcc; return bcc;
} }
/**
* 编辑状态的时候需要重新绘制下边框
*
*/
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if(isEditing){
g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE);
}else if(!isHovering){
super.paintBorder(g, bounds);
}
}
/** /**
* 渲染Painter * 渲染Painter
*/ */
public void paint(Graphics g) { public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize()); designerEditor.paintEditor(g, this.getSize());
super.paint(g); super.paint(g);
if(isEditing){
g.setColor(INNER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM);
}
} }
/** /**
@ -270,6 +297,14 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return coverPanel; return coverPanel;
} }
/**
* 是否支持设置可用
* return boolean
*/
public boolean supportSetEnable(){
return false;
}
/** /**
* data属性改变触发其他操作 * data属性改变触发其他操作
* *

240
designer-form/src/com/fr/design/designer/creator/XCreator.java

@ -3,7 +3,8 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.GraphHelper;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
@ -14,6 +15,7 @@ import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.AuthorityPropertyPane;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.NoSupportAuthorityEdit;
@ -21,6 +23,7 @@ import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -32,6 +35,7 @@ import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
@ -55,14 +59,15 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
protected Widget data; protected Widget data;
protected JComponent editor; protected JComponent editor;
protected CoverReportPane coverPanel;
// XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度 // XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度
private int[] directions; private int[] directions;
private Rectangle backupBound; private Rectangle backupBound;
private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性 private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性
private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上 private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上
private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置 private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置
public XCreator(Widget ob, Dimension initSize) { public XCreator(Widget ob, Dimension initSize) {
this.data = ob; this.data = ob;
this.initEditor(); this.initEditor();
@ -72,12 +77,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
add(editor, BorderLayout.CENTER); add(editor, BorderLayout.CENTER);
} }
if (initSize.width == 0) { setInitSize(initSize);
initSize.width = this.initEditorSize().width;
}
if (initSize.height == 0) {
initSize.height = this.initEditorSize().height;
}
this.setPreferredSize(initSize); this.setPreferredSize(initSize);
this.setSize(initSize); this.setSize(initSize);
this.setMaximumSize(initSize); this.setMaximumSize(initSize);
@ -101,6 +101,18 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
} }
/**
* 初始化组件大小
*/
public void setInitSize(Dimension initSize) {
if (initSize.width == 0) {
initSize.width = this.initEditorSize().width;
}
if (initSize.height == 0) {
initSize.height = this.initEditorSize().height;
}
}
/** /**
* 备份当前大小 * 备份当前大小
*/ */
@ -241,8 +253,8 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
protected String getIconName() { protected String getIconName() {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
public String getIconPath() { public String getIconPath() {
return "/com/fr/web/images/form/resources/" + getIconName(); return "/com/fr/web/images/form/resources/" + getIconName();
@ -282,8 +294,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
*@param formEditor 设计界面组件 *@param formEditor 设计界面组件
*@return 工具界面 *@return 工具界面
*/ */
@Override
public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) { public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) {
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
if (isDedicateContainer()) { if (isDedicateContainer()) {
// 图表块和报表块由于控件树处不显示,但对应的属性表要显示,此处处理下 // 图表块和报表块由于控件树处不显示,但对应的属性表要显示,此处处理下
XCreator child = ((XLayoutContainer) this).getXCreator(0); XCreator child = ((XLayoutContainer) this).getXCreator(0);
@ -317,21 +330,21 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return false; return false;
} }
/** /**
* 该组件是否可以拖入参数面板 * 该组件是否可以拖入参数面板
* @return 是则返回true * @return 是则返回true
*/ */
public boolean canEnterIntoParaPane(){ public boolean canEnterIntoParaPane(){
return true; return true;
} }
/** /**
* 该组件是否可以拖入表单主体 * 该组件是否可以拖入表单主体
* @return 是则返回true * @return 是则返回true
*/ */
public boolean canEnterIntoAdaptPane(){ public boolean canEnterIntoAdaptPane(){
return true; return true;
} }
/** /**
* 该组件是否可以拖入绝对布局 * 该组件是否可以拖入绝对布局
@ -341,27 +354,27 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return true; return true;
} }
/** /**
* 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽)
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isSupportDrag(){ public boolean isSupportDrag(){
return true; return true;
} }
public List<String> getAllXCreatorNameList(XCreator xCreator, List<String> namelist){ public List<String> getAllXCreatorNameList(XCreator xCreator, List<String> namelist){
namelist.add(xCreator.toData().getWidgetName()); namelist.add(xCreator.toData().getWidgetName());
return namelist; return namelist;
} }
/** /**
* 是否有查询按钮 * 是否有查询按钮
* @param xCreator 控件或容器 * @param xCreator 控件或容器
* @return 有无查询按钮 * @return 有无查询按钮
*/ */
public boolean SearchQueryCreators(XCreator xCreator) { public boolean SearchQueryCreators(XCreator xCreator) {
return false; return false;
} }
/** /**
* @return the backupBound * @return the backupBound
@ -381,14 +394,25 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 控件树不显示此组件 * 控件树不显示此组件
* @param path 控件树list * @param path 控件树list
*/ */
public void notShowInComponentTree(ArrayList<Component> path) { @Override
public void notShowInComponentTree(List<Component> path) {
return; return;
} }
/**
* 获取其在控件树上可见父层
* @return 组件
*/
@Override
public Component getParentShow(){
return this.getParent();
}
/** /**
* 重置组件的名称 * 重置组件的名称
* @param name 名称 * @param name 名称
*/ */
@Override
public void resetCreatorName(String name) { public void resetCreatorName(String name) {
toData().setWidgetName(name); toData().setWidgetName(name);
} }
@ -405,6 +429,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 返回编辑的子组件scale为其内部组件 * 返回编辑的子组件scale为其内部组件
* @return 组件 * @return 组件
*/ */
@Override
public XCreator getEditingChildCreator() { public XCreator getEditingChildCreator() {
return this; return this;
} }
@ -413,6 +438,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 返回对应属性表的组件scale和title返回其子组件 * 返回对应属性表的组件scale和title返回其子组件
* @return 组件 * @return 组件
*/ */
@Override
public XCreator getPropertyDescriptorCreator() { public XCreator getPropertyDescriptorCreator() {
return this; return this;
} }
@ -421,6 +447,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 更新子组件的Bound; 没有不处理 * 更新子组件的Bound; 没有不处理
* @param minHeight 最小高度 * @param minHeight 最小高度
*/ */
@Override
public void updateChildBound(int minHeight) { public void updateChildBound(int minHeight) {
return; return;
} }
@ -429,6 +456,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 是否作为控件树的叶子节点 * 是否作为控件树的叶子节点
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isComponentTreeLeaf() { public boolean isComponentTreeLeaf() {
return true; return true;
} }
@ -437,23 +465,24 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 是否为sclae和title专属容器 * 是否为sclae和title专属容器
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isDedicateContainer() { public boolean isDedicateContainer() {
return false; return false;
} }
/** /**
* 是否接收这种类型 * 是否接收这种类型
* @param acceptTypes 接收的类型 * @param acceptTypes 接收的类型
* @return 接收指定的类型则返回true,否则返回false * @return 接收指定的类型则返回true,否则返回false
*/ */
public boolean acceptType(Class<?>... acceptTypes) { public boolean acceptType(Class<?>... acceptTypes) {
for (Class<?> type : acceptTypes) { for (Class<?> type : acceptTypes) {
if (StableUtils.objectInstanceOf(this, type)) { if (StableUtils.objectInstanceOf(this, type)) {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* 是否组件要缩放(自适应里部分组件需要, 如数字文本下拉框下拉复选框密码下拉树下拉复选树日期) * 是否组件要缩放(自适应里部分组件需要, 如数字文本下拉框下拉复选框密码下拉树下拉复选树日期)
@ -580,7 +609,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
/** /**
* 组件是否是共享组件 * 组件是否是共享组件
* @return 是否是共享组件 * @return 是否是共享组件
*/ */
public boolean isShared() { public boolean isShared() {
return StringUtils.isNotEmpty(shareId); return StringUtils.isNotEmpty(shareId);
} }
@ -596,7 +625,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
/** /**
* 焦点是否在帮助按钮上 * 焦点是否在帮助按钮上
* @return 焦点是否在帮助按钮上 * @return 焦点是否在帮助按钮上
*/ */
public boolean isHelpBtnOnFocus() { public boolean isHelpBtnOnFocus() {
return isHelpBtnOnFocus; return isHelpBtnOnFocus;
} }
@ -608,18 +637,41 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
/** /**
* 设置描述信息 * 设置描述信息
* @param msg 帮助信息 * @param msg 帮助信息
*/ */
public void setXDescrption(String msg){} public void setXDescrption(String msg){
if (coverPanel != null) {
coverPanel.setHelpMsg(msg);
}
}
public JComponent getCoverPane(){
return coverPanel;
}
/**
* 销毁帮助提示框
*/
public void destroyHelpDialog(){
if (coverPanel != null) {
coverPanel.destroyHelpDialog();
}
}
/**
* 是否展现覆盖的pane
* @param display 是否
*/
public void displayCoverPane(boolean display){
}
/** /**
* 根据widget设置Xcreator描述信息 * 根据widget设置Xcreator描述信息
* @param widget * @param widget
*/ */
public void setXDescrption(Widget widget){ public void setXDescrption(Widget widget){
if (widget != null) { if (widget != null) {
setXDescrption(widget.getDescription()); setXDescrption(widget.getDescription());
} }
} }
/** /**
@ -667,39 +719,55 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* *
*/ */
public void firePropertyChange(){ public void firePropertyChange(){
// do nothing // do nothing
}
/**
* 有的控件是有编辑状态的给一个退出编辑的接口
*
*/
public void stopEditing() {
// do nothing
} }
/** /**
* 有的控件是有编辑状态的给一个退出编辑的接口 * 编辑状态的时候需要重新绘制下边框
* *
*/ */
public void stopEditing() { public void paintBorder(Graphics g, Rectangle bounds){
// do nothing GraphHelper.draw(g, bounds, Constants.LINE_MEDIUM);
} }
/** /**
* 创建右击弹出菜单 * 创建右击弹出菜单
* *
*/ */
public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { public UIPopupMenu createPopupMenu(FormDesigner formDesigner) {
UpdateAction[] actions = formDesigner.getActions(); UpdateAction[] actions = formDesigner.getActions();
UIPopupMenu popup = new UIPopupMenu(); UIPopupMenu popup = new UIPopupMenu();
for (int i = 0; i < actions.length; i++) { for (int i = 0; i < actions.length; i++) {
if (i == SHORTS_SEPARATOR_POS) { if (i == SHORTS_SEPARATOR_POS) {
popup.addSeparator(); popup.addSeparator();
} }
popup.add(actions[i].createMenuItem()); popup.add(actions[i].createMenuItem());
} }
return popup; return popup;
} }
/** /**
* 是否支持上移一层下移一层等操作 * 是否支持上移一层下移一层等操作
* *
*/ */
public boolean isMovable() { public boolean isMovable() {
return true; return true;
} }
/**
* 是否支持共享-现只支持报表块图表tab块绝对布局
* @return
*/
public boolean isSupportShared() {
return false;
}
} }

26
designer-form/src/com/fr/design/designer/creator/XCreatorTools.java

@ -1,15 +1,15 @@
/** /**
* *
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Component; import java.awt.Component;
import java.util.ArrayList; import java.util.List;
/** /**
* @author jim * @author jim
* @date 2014-11-7 * @date 2014-11-7
* *
*/ */
public interface XCreatorTools { public interface XCreatorTools {
@ -17,42 +17,46 @@ public interface XCreatorTools {
* 控件树不显示此组件 * 控件树不显示此组件
* @param path 控件树list * @param path 控件树list
*/ */
void notShowInComponentTree(ArrayList<Component> path); void notShowInComponentTree(List<Component> path);
/** /**
* 重置组件的名称 * 重置组件的名称
* @param name 名称 * @param name 名称
*/ */
void resetCreatorName(String name); void resetCreatorName(String name);
/** /**
* 返回编辑的子组件scale为其内部组件 * 返回编辑的子组件scale为其内部组件
* @return 组件 * @return 组件
*/ */
XCreator getEditingChildCreator(); XCreator getEditingChildCreator();
/** /**
* 返回对应属性表的组件scale和title返回其子组件 * 返回对应属性表的组件scale和title返回其子组件
* @return 组件 * @return 组件
*/ */
XCreator getPropertyDescriptorCreator(); XCreator getPropertyDescriptorCreator();
/** /**
* 更新子组件的Bound; 没有不处理 * 更新子组件的Bound; 没有不处理
* @param minHeight 最小高度 * @param minHeight 最小高度
*/ */
void updateChildBound(int minHeight); void updateChildBound(int minHeight);
/** /**
* 是否作为控件树的叶子节点 * 是否作为控件树的叶子节点
* @return 是则返回true * @return 是则返回true
*/ */
boolean isComponentTreeLeaf(); boolean isComponentTreeLeaf();
/** /**
* 是否为sclae和title专属容器 * 是否为sclae和title专属容器
* @return 是则返回true * @return 是则返回true
*/ */
boolean isDedicateContainer(); boolean isDedicateContainer();
/**
* 获取其在控件树上可见父层
* @return 组件
*/
Component getParentShow();
} }

16
designer-form/src/com/fr/design/designer/creator/XElementCase.java

@ -38,6 +38,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private CoverReportPane coverPanel; private CoverReportPane coverPanel;
private FormDesigner designer; private FormDesigner designer;
private static BufferedImage DEFAULT_BACKGROUND; private static BufferedImage DEFAULT_BACKGROUND;
private boolean isHovering = false;
static{ static{
try{ try{
@ -122,7 +123,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
if (editor.getFitStateInPC() == 0) { if (editor.getFitStateInPC() == 0) {
editor.setReportFitAttr(null); 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); PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr);
if (editor.getReportFitAttr() == null) { if (editor.getReportFitAttr() == null) {
editor.setReportFitInPc(processor.getFitStateInPC(fitAttr)); editor.setReportFitInPc(processor.getFitStateInPC(fitAttr));
@ -211,6 +216,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* @param display 是否 * @param display 是否
*/ */
public void displayCoverPane(boolean display){ public void displayCoverPane(boolean display){
isHovering = display;
coverPanel.setVisible(display); coverPanel.setVisible(display);
coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight()); coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight());
editor.repaint(); editor.repaint();
@ -227,6 +233,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return coverPanel; return coverPanel;
} }
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if (!isHovering) {
super.paintBorder(g, bounds);
}
}
/** /**
* 初始化大小 * 初始化大小
* @return 尺寸 * @return 尺寸

4
designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java

@ -241,6 +241,10 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
} }
} }
public int getShowXCreatorCount() {
return getXCreatorCount();
}
public int getXCreatorCount() { public int getXCreatorCount() {
return getComponentCount(); return getComponentCount();
} }

15
designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -89,6 +89,21 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
}; };
} }
/**
* 获取其在控件树上可见父层
* @return 组件
*/
@Override
public Component getParentShow(){
//绝对布局作为body的时候不显示自适应布局父层
if ((this.getParent() != null)) {
return ((XCreator) this.getParent()).getParentShow();
}
return super.getParentShow();
}
@Override @Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)}; return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)};

86
designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -3,6 +3,9 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.GraphHelper;
import com.fr.base.iofileattr.SharableAttrMark;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
@ -11,10 +14,14 @@ import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetHelpDialog;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.Connector; import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
@ -23,8 +30,20 @@ import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen; import com.fr.general.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.share.ShareConstants;
import java.awt.*; import com.fr.stable.Constants;
import javax.swing.Icon;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -38,14 +57,20 @@ import java.util.HashMap;
*/ */
public class XWAbsoluteLayout extends XLayoutContainer { public class XWAbsoluteLayout extends XLayoutContainer {
private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_WIDTH = 75;
private static final int EDIT_BTN_HEIGHT = 24; private static final int EDIT_BTN_HEIGHT = 20;
private int minWidth = WLayout.MIN_WIDTH; private int minWidth = WLayout.MIN_WIDTH;
private int minHeight = WLayout.MIN_HEIGHT; private int minHeight = WLayout.MIN_HEIGHT;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249);
private static final int BORDER_WIDTH = 1;
private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0; protected double containerPercent = 1.0;
private boolean isHovering = false;
private HashMap<Connector, XConnector> xConnectorMap; private HashMap<Connector, XConnector> xConnectorMap;
public XWAbsoluteLayout() { public XWAbsoluteLayout() {
@ -437,15 +462,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
//画白色的编辑层 //画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(Color.WHITE); g2d.setColor(XCreatorConstants.COVER_COLOR);
g2d.fillRect(x, y, w, h); g2d.fillRect(x, y, w, h);
//画编辑按钮所在框 //画编辑按钮所在框
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f);
g2d.setColor(XCreatorConstants.EDIT_COLOR);
g2d.setComposite(alphaComposite);
g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4);
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标 //画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH);
g2d.drawImage( g2d.drawImage(
image, image,
(x + w / 2 - 23), (x + w / 2 - 23),
@ -455,12 +483,37 @@ public class XWAbsoluteLayout extends XLayoutContainer {
null, null,
this this
); );
g2d.setColor(Color.BLACK); g2d.setColor(Color.WHITE);
//画编辑文字 //画编辑文字
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5);
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM);
paintExtro(g);
} }
} }
public void paintExtro(Graphics g) {
if (this.toData().getWidgetAttrMark(SharableAttrMark.XML_TAG) != null) {
int width = getWidth() - ShareConstants.SHARE_EL_CONTROL_BUTTON_HW;
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillArc(width, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW,
0, 360);
controlMode.paintIcon(this, g, width, 0);
}
}
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if(editable){
g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 5, bounds.height + 5), Constants.LINE_LARGE);
g.setColor(INNER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height), Constants.LINE_MEDIUM);
}else if(!isMouseEnter){
super.paintBorder(g, bounds);
}
}
/** /**
* 响应点击事件 * 响应点击事件
* *
@ -468,6 +521,11 @@ public class XWAbsoluteLayout extends XLayoutContainer {
* @param e 鼠标点击事件 * @param e 鼠标点击事件
*/ */
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
//帮助弹窗
if (this.isHelpBtnOnFocus()) {
new WidgetHelpDialog(DesignerContext.getDesignerFrame(), this.toData().getDescription()).showWindow(e);
return;
}
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = isEditable() || boolean isEditing = isEditable() ||
@ -523,4 +581,12 @@ public class XWAbsoluteLayout extends XLayoutContainer {
public boolean supportInnerOrderChangeActions() { public boolean supportInnerOrderChangeActions() {
return true; return true;
} }
/**
* 是否支持共享-现只支持报表块图表tab块绝对布局
* @return
*/
public boolean isSupportShared() {
return true;
}
} }

901
designer-form/src/com/fr/design/designer/creator/XWFitLayout.java

File diff suppressed because it is too large Load Diff

5
designer-form/src/com/fr/design/designer/creator/XWParameterLayout.java

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

14
designer-form/src/com/fr/design/designer/creator/XWTitleLayout.java

@ -111,6 +111,20 @@ public class XWTitleLayout extends DedicateLayoutContainer {
return null; return null;
} }
/**
* 编辑状态的时候需要重新绘制下边框
*
*/
@Override
public void paintBorder(Graphics g, Rectangle bounds) {
XCreator childCreator = getEditingChildCreator();
if (childCreator != null) {
childCreator.paintBorder(g, bounds);
}
}
/** /**
* 将WLayout转换为XLayoutContainer * 将WLayout转换为XLayoutContainer
*/ */

7
designer-form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java

@ -2,9 +2,10 @@ package com.fr.design.designer.creator.cardlayout;
import com.fr.design.designer.beans.actions.FormUndoableAction; import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.log.FineLoggerFactory; import com.fr.general.FRLogger;
/** /**
* Created by zhouping on 2017/2/17. * Created by zhouping on 2017/2/17.
@ -35,9 +36,11 @@ public class TabMoveAction extends FormUndoableAction {
moveTabAction(xwCardTagLayout, currentButton, xCurrentTab, currentTab); moveTabAction(xwCardTagLayout, currentButton, xCurrentTab, currentTab);
xwCardTagLayout.setSwitchingTab(false); xwCardTagLayout.setSwitchingTab(false);
xwCardTagLayout.doLayout();
FormHierarchyTreePane.getInstance().refreshDockingView();
}catch (Exception e){ }catch (Exception e){
xwCardTagLayout.setSwitchingTab(false); xwCardTagLayout.setSwitchingTab(false);
FineLoggerFactory.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
return false; return false;
} }
return true; return true;

39
designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -1,7 +1,6 @@
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -17,25 +16,23 @@ import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.cardtag.DefaultTemplateStyle;
import javax.swing.Icon; import javax.swing.Icon;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
public class XCardAddButton extends XButton{ public class XCardAddButton extends XButton {
private XWCardTagLayout tagLayout; private XWCardTagLayout tagLayout;
private XWCardLayout cardLayout; private XWCardLayout cardLayout;
private static final int LEFT_GAP = 5;
private static final int UP_GAP = 10;
private static final int START_INDEX = 3;
private static final int INDEX = 0;
private static final int DEFAULT_BUTTON_WIDTH = 80; private static final int DEFAULT_BUTTON_WIDTH = 80;
private static final int ICON_OFFSET = 8;
private static Icon ADD_ICON = BaseUtils.readIcon("/com/fr/design/form/images/add.png"); private static Icon ADD_ICON = BaseUtils.readIcon("/com/fr/design/form/images/add.png");
private Icon addIcon = ADD_ICON; private Icon addIcon = ADD_ICON;
@ -74,7 +71,7 @@ public class XCardAddButton extends XButton{
* @param widget 按钮 * @param widget 按钮
* @param initSize 大小 * @param initSize 大小
*/ */
public XCardAddButton(CardAddButton widget, Dimension initSize,XWCardTagLayout fit,XWCardLayout cardLayout) { public XCardAddButton(CardAddButton widget, Dimension initSize, XWCardTagLayout fit, XWCardLayout cardLayout) {
super(widget, initSize); super(widget, initSize);
this.tagLayout = fit; this.tagLayout = fit;
this.cardLayout = cardLayout; this.cardLayout = cardLayout;
@ -86,7 +83,8 @@ public class XCardAddButton extends XButton{
* @param e 点击事件 * @param e 点击事件
* *
*/ */
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ @Override
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
designer.fireTargetModified(); designer.fireTargetModified();
@ -126,14 +124,17 @@ public class XCardAddButton extends XButton{
this.cardLayout = borderLayout.getCardPart(); this.cardLayout = borderLayout.getCardPart();
} }
public void paintComponent(Graphics g) { @Override
public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
drawAddIcon(g2d); drawAddIcon(g2d);
} }
private void drawAddIcon(Graphics2D g2d){ private void drawAddIcon(Graphics2D g2d){
addIcon.paintIcon(this, g2d,LEFT_GAP,UP_GAP); int width = this.getWidth();
int height = this.getHeight();
addIcon.paintIcon(this, g2d, width / 2 - ICON_OFFSET, height / 2 - ICON_OFFSET);
} }
//将原来的tab页设置为未选中状态 //将原来的tab页设置为未选中状态
@ -152,11 +153,14 @@ public class XCardAddButton extends XButton{
String cardLayoutName = cardLayout.toData().getWidgetName(); String cardLayoutName = cardLayout.toData().getWidgetName();
CardSwitchButton titleButton = new CardSwitchButton(index,cardLayoutName); CardSwitchButton titleButton = new CardSwitchButton(index,cardLayoutName);
WCardTagLayout layout = (WCardTagLayout) this.tagLayout.toData();
if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){
titleButton.setInitialBackground(layout.getTemplateStyle().getTabDefaultBackground());
titleButton.setCustomStyle(true);
}
//设置标题 //设置标题
titleButton.setText(getTabTitleName()); titleButton.setText(getTabTitleName(layout));
titleButton.setInitialBackground(ColorBackground.getInstance(Color.WHITE));
XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout); XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout);
titleButton.setCustomStyle(true);
titleButton.setShowButton(true); titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout); showButton.setBackupParent(tagLayout);
this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setCurrentCard(titleButton);
@ -165,7 +169,7 @@ public class XCardAddButton extends XButton{
} }
//切换焦点到新增tab页 //切换焦点到新增tab页
private void showNewTab(EditingMouseListener editingMouseListener,int index){ private void showNewTab(EditingMouseListener editingMouseListener, int index){
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index); XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index);
XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index); XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index);
@ -174,8 +178,7 @@ public class XCardAddButton extends XButton{
} }
//新增时去tabFitLayout名字中最大的Index+1,防止重名 //新增时去tabFitLayout名字中最大的Index+1,防止重名
private String getTabTitleName(){ private String getTabTitleName(WCardTagLayout layout){
WCardTagLayout layout = (WCardTagLayout) this.tagLayout.toData();
int size = layout.getWidgetCount(); int size = layout.getWidgetCount();
String prefix = Inter.getLocText("FR-Designer_Title"); String prefix = Inter.getLocText("FR-Designer_Title");
String newTextName = prefix + size; String newTextName = prefix + size;

244
designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -4,6 +4,7 @@
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
@ -30,19 +31,25 @@ import com.fr.general.Background;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.unit.PT;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicLabelUI;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
/** /**
* *
@ -65,20 +72,21 @@ public class XCardSwitchButton extends XButton {
private static final int MIN_SIZE = 1; private static final int MIN_SIZE = 1;
// 删除按钮识别区域偏移量 // 删除按钮识别区域偏移量
private static final int RIGHT_OFFSET = 15; private static final int CLOSE_ICON_RIGHT_OFFSET = 15;
private static final int TOP_OFFSET = 25; private static final int CLOSE_ICON_TOP_OFFSET = 15;
//这边先不计算button的高度,涉及到layout那边的整体高度,先用之前的固定高度
private static final int DEFAULT_BUTTON_HEIGHT = 36;
// tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量 // tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量
private static final int FONT_SIZE_ADJUST = 2; private static final int FONT_SIZE_ADJUST = 2;
//文字竖排时用来计算文字大小
private static final int RESLUTION = 120;
private XWCardLayout cardLayout; private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout; private XWCardTagLayout tagLayout;
private Background selectBackground; private Background selectBackground;
private boolean isCustomStyle;
private UILabel label; private UILabel label;
private Icon closeIcon = MOUSE_CLOSE; private Icon closeIcon = MOUSE_CLOSE;
@ -99,14 +107,6 @@ public class XCardSwitchButton extends XButton {
this.cardLayout = cardLayout; this.cardLayout = cardLayout;
} }
public boolean isCustomStyle() {
return isCustomStyle;
}
public void setCustomStyle(boolean customStyle) {
isCustomStyle = customStyle;
}
public Background getSelectBackground() { public Background getSelectBackground() {
return selectBackground; return selectBackground;
} }
@ -125,11 +125,10 @@ public class XCardSwitchButton extends XButton {
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) { public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
} }
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize, public XCardSwitchButton(CardSwitchButton widget, Dimension initSize,
XWCardLayout cardLayout, XWCardTagLayout tagLayout) { XWCardLayout cardLayout, XWCardTagLayout tagLayout) {
super(widget, initSize); super(widget, initSize);
this.cardLayout = cardLayout; this.cardLayout = cardLayout;
this.tagLayout = tagLayout; this.tagLayout = tagLayout;
@ -144,19 +143,19 @@ public class XCardSwitchButton extends XButton {
* 点击事件 * 点击事件
* *
*/ */
@Override
public void respondClick(EditingMouseListener editingMouseListener, public void respondClick(EditingMouseListener editingMouseListener,
MouseEvent e) { MouseEvent e) {
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
//关闭重新打开,相关的layout未存到xml中,初始化 //关闭重新打开,相关的layout未存到xml中,初始化
if(cardLayout == null){ if(cardLayout == null){
initRelateLayout(this); initRelateLayout();
} }
//获取当前tab的index //获取当前tab的index
XCardSwitchButton button = this; CardSwitchButton currentButton = (CardSwitchButton) this.toData();
CardSwitchButton currentButton = (CardSwitchButton) button.toData();
int index = currentButton.getIndex(); int index = currentButton.getIndex();
int maxIndex = cardLayout.getComponentCount() - 1; int maxIndex = cardLayout.getComponentCount() - 1;
@ -167,14 +166,13 @@ public class XCardSwitchButton extends XButton {
deleteTabLayout(selectionModel, designer); deleteTabLayout(selectionModel, designer);
return; return;
} }
deleteCard(button,index); deleteCard(this, index);
this.tagLayout.adjustComponentWidth();
designer.fireTargetModified(); designer.fireTargetModified();
LayoutUtils.layoutRootContainer(designer.getRootComponent()); LayoutUtils.layoutRootContainer(designer.getRootComponent());
FormHierarchyTreePane.getInstance().refreshRoot(); FormHierarchyTreePane.getInstance().refreshRoot();
return; return;
} }
//将当前tab按钮改为选中状态 //将当前tab按钮改为选中状态
changeButtonState(index); changeButtonState(index);
@ -220,7 +218,7 @@ public class XCardSwitchButton extends XButton {
} }
//删除card,同时修改其他switchbutton和tabfit的index //删除card,同时修改其他switchbutton和tabfit的index
private void deleteCard(XCardSwitchButton button,int index){ private void deleteCard(XCardSwitchButton button, int index){
String titleName = button.getContentLabel().getText(); String titleName = button.getContentLabel().getText();
int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”", 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);
@ -250,7 +248,7 @@ public class XCardSwitchButton extends XButton {
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取 //SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
private void initRelateLayout(XCardSwitchButton button){ private void initRelateLayout(){
this.tagLayout = (XWCardTagLayout)this.getBackupParent(); this.tagLayout = (XWCardTagLayout)this.getBackupParent();
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent(); XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent();
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent();
@ -273,7 +271,7 @@ public class XCardSwitchButton extends XButton {
double mainY = point.getY(); double mainY = point.getY();
// 参数界面对坐标的影响 // 参数界面对坐标的影响
JForm jform = (JForm)HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(jform.getFormDesign().getParaComponent() != null){ if(jform.getFormDesign().getParaComponent() != null){
ey -= jform.getFormDesign().getParaHeight(); ey -= jform.getFormDesign().getParaHeight();
} }
@ -281,36 +279,38 @@ public class XCardSwitchButton extends XButton {
//减掉tab布局的相对位置 //减掉tab布局的相对位置
ex -= mainX; ex -= mainX;
ey -= mainY; ey -= mainY;
XLayoutContainer titleLayout = tagLayout.getBackupParent();
Point titlePoint = titleLayout.getLocation();
// button position // button position
XCardSwitchButton button = this; XCardSwitchButton button = this;
Point position = button.getLocation(); Point position = button.getLocation();
int width = button.getWidth(); int width = button.getWidth();
int height = button.getHeight();
ey = ey % DEFAULT_BUTTON_HEIGHT;
// 鼠标进入按钮右侧删除图标区域 // 鼠标进入按钮右侧删除图标区域
double recX = position.getX() + (width - RIGHT_OFFSET); double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET);
double recY = position.getY() + (height - TOP_OFFSET); double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET;
return (recX < ex && ex < recX + RIGHT_OFFSET && ey < recY); return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY());
} }
//将当前switchButton改为选中状态 //将当前switchButton改为选中状态
private void changeButtonState(int index){ private void changeButtonState(int index) {
for(int i=0;i<this.tagLayout.getComponentCount();i++){ for (int i = 0; i < this.tagLayout.getComponentCount(); i++) {
XCardSwitchButton temp = (XCardSwitchButton) tagLayout.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) tagLayout.getComponent(i);
CardSwitchButton tempButton = (CardSwitchButton) temp.toData(); CardSwitchButton tempButton = (CardSwitchButton) temp.toData();
tempButton.setShowButton(tempButton.getIndex()==index); tempButton.setShowButton(tempButton.getIndex() == index);
} }
} }
public void paintComponent(Graphics g) { @Override
public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
drawBackground(); CardSwitchButton button = (CardSwitchButton) this.toData();
drawTitle(); WidgetTitle widgetTitle = getWidgetTitle();
drawBackground(button, widgetTitle);
drawTitle(button, widgetTitle);
Dimension panelSize = this.getContentLabel().getSize(); Dimension panelSize = this.getContentLabel().getSize();
this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight()));
drawCloseIcon(g2d); drawCloseIcon(g2d);
@ -318,77 +318,49 @@ public class XCardSwitchButton extends XButton {
//画删除图标 //画删除图标
private void drawCloseIcon(Graphics2D g2d){ private void drawCloseIcon(Graphics2D g2d){
closeIcon.paintIcon(this, g2d,this.getWidth()-LEFT_GAP,0); closeIcon.paintIcon(this, g2d, this.getWidth() - LEFT_GAP, 0);
} }
//画背景 //画背景
private void drawBackground(){ private void drawBackground(CardSwitchButton button, WidgetTitle widgetTitle){
CardSwitchButton button = (CardSwitchButton)this.toData(); Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground();
Background currentBackground; TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle();
currentBackground = this.getSelectBackground(); //获取当前tab的index
//这边就是button的背景图片,图片的是image,默认的是color,所以不应该是针对null的判断 CardSwitchButton currentButton = (CardSwitchButton) this.toData();
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULT_TYPE; int index = currentButton.getIndex();
if (type.equals(COLOR_BACKGROUND_TYPE) || type.equals(DEFAULT_TYPE)) { XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index);
ColorBackground background; WTabFitLayout wTabFitLayout = tabFitLayout.getWTabFitLayout();
if(button.isShowButton()){ Background initialBackground = wTabFitLayout.getInitialBackground();
this.rebuid(); Background selectBackground = wTabFitLayout.getClickBackground();
background = ColorBackground.getInstance(CHOOSED_GRAL); if (button.isShowButton()) {
this.setContentBackground(background); this.setContentBackground(selectBackground == null ? templateStyle.getSelectBackground() : selectBackground);
}else{ } else {
this.rebuid(); this.setContentBackground(initialBackground == null ? background : initialBackground);
background = ColorBackground.getInstance(NORMAL_GRAL);
this.setContentBackground(background);
}
} }
} }
//画标题 //画标题
private void drawTitle() { private void drawTitle(CardSwitchButton button, WidgetTitle widgetTitle) {
CardSwitchButton button = (CardSwitchButton) this.toData();
String titleText = 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); this.setButtonText(titleText);
if (this.cardLayout == null) { FRFont font = widgetTitle.getFrFont();
initRelateLayout(this); FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
}
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
// 标题部分
WidgetTitle title = style.getTitle();
FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
UILabel label = this.getContentLabel(); UILabel label = this.getContentLabel();
label.setFont(newFont); label.setFont(newFont);
label.setForeground(font.getForeground()); label.setForeground(font.getForeground());
Background background = title.getBackground();
if (background != null) { }
if(button.isShowButton() && selectBackground != null){
this.setContentBackground(selectBackground); private WidgetTitle getWidgetTitle() {
}else if (button.isShowButton() && selectBackground == null){ if (this.cardLayout == null) {
background = ColorBackground.getInstance(CHOOSED_GRAL); initRelateLayout();
this.setContentBackground(background);
} else {
this.setContentBackground(background);
}
} }
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
return style.getTitle();
} }
//删除tab布局 //删除tab布局
private void deleteTabLayout(SelectionModel selectionModel,FormDesigner designer){ private void deleteTabLayout(SelectionModel selectionModel, FormDesigner designer){
String titleName = this.getContentLabel().getText(); String titleName = this.getContentLabel().getText();
int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”", 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);
@ -427,6 +399,10 @@ public class XCardSwitchButton extends XButton {
public XCreator getXCreator() { public XCreator getXCreator() {
//根据index获取对应的tabFitLayout //根据index获取对应的tabFitLayout
int index = ((CardSwitchButton) this.toData()).getIndex(); int index = ((CardSwitchButton) this.toData()).getIndex();
//关闭重新打开,相关的layout未存到xml中,初始化
if(cardLayout == null){
initRelateLayout();
}
return (XCreator) cardLayout.getComponent(index); return (XCreator) cardLayout.getComponent(index);
} }
@ -437,9 +413,89 @@ public class XCardSwitchButton extends XButton {
label = this.getContentLabel(); label = this.getContentLabel();
} }
@Override
public void firePropertyChange() { public void firePropertyChange() {
super.firePropertyChange(); super.firePropertyChange();
tagLayout.setTabsAndAdjust(); tagLayout.setTabsAndAdjust();
repaint(); repaint();
} }
@Override
protected UILabel initContentLabel() {
return new CardSwitchBtnLabel();
}
public class CardSwitchBtnLabel extends UILabel {
public CardSwitchBtnLabel() {
updateUI();
}
@Override
public void updateUI() {
setUI(new CardSwitchBtnLabelUI());
}
}
public class CardSwitchBtnLabelUI extends BasicLabelUI {
private static final int DOT_COUNT = 3;
private static final String DOT = ".";
private static final int DOTS_LINESPACE = 6;
private static final int DOTS_HEIGHT = 10;
@Override
public void paint(Graphics g, JComponent c) {
WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData();
if (ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)) {
//绘制文本竖排展示
paintVerticalText(g);
} else {
super.paint(g, c);
}
}
private void paintVerticalText(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int width = XCardSwitchButton.this.getWidth();
int height = XCardSwitchButton.this.getHeight();
CardSwitchButton button = (CardSwitchButton) XCardSwitchButton.this.toData();
String titleText = button.getText();
java.util.List verticalTextList = new ArrayList();
StringBuilder titleStringBuf = new StringBuilder();
WidgetTitle title = getWidgetTitle();
FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST);
FontMetrics fm = GraphHelper.getFontMetrics(newFont);
for (int i = 0; i < titleText.length(); i++) {
titleStringBuf.append(titleText.charAt(i));
verticalTextList.add(titleStringBuf.substring(0, titleStringBuf.length()));
titleStringBuf.delete(0, titleStringBuf.length());
}
int textAscent = fm.getAscent();
int textHeight = fm.getHeight();
int textY = 0;
textY += textAscent;
for (int i = 0; i < verticalTextList.size(); i++) {
String paint_str = (String) verticalTextList.get(i);
GraphHelper.drawString(g2d, paint_str, (width - fm.stringWidth(paint_str)) / 2, textY);
textY += textHeight;
textY += PT.pt2pix(0, RESLUTION);
if (textY > height - textHeight && i < verticalTextList.size() - 1) {
textY -= DOTS_HEIGHT;
paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / 2);
break;
}
}
}
public void paintDots(Graphics2D g2d, int startY, int startX) {
for (int i = 0; i < DOT_COUNT; i++) {
GraphHelper.drawString(g2d, DOT, startX, startY);
startY += DOTS_LINESPACE;
startY += PT.pt2pix(0, RESLUTION);
}
}
}
} }

70
designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -31,8 +31,11 @@ import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -40,9 +43,11 @@ import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.util.List;
/** /**
* @author richer * @author richer
@ -55,6 +60,11 @@ public class XWCardLayout extends XLayoutContainer {
private static final int NORTH = 0; private static final int NORTH = 0;
private FormDesigner designer; private FormDesigner designer;
private static final int LAYOUT_INDEX = 0;
public static final String DEFAULT_NAME = "cardlayout";
//默认蓝色标题背景 //默认蓝色标题背景
private static final Color TITLE_COLOR = new Color(51, 132, 240); private static final Color TITLE_COLOR = new Color(51, 132, 240);
@ -76,8 +86,9 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午6:22:40 * @date 2014-11-25-下午6:22:40
* *
*/ */
@Override
public String createDefaultName() { public String createDefaultName() {
return "cardlayout"; return DEFAULT_NAME;
} }
/** /**
@ -89,7 +100,8 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午6:22:17 * @date 2014-11-25-下午6:22:17
* *
*/ */
public WCardLayout toData() { @Override
public WCardLayout toData() {
return (WCardLayout) data; return (WCardLayout) data;
} }
@ -97,6 +109,7 @@ public class XWCardLayout extends XLayoutContainer {
* 初始化时默认的组件大小 * 初始化时默认的组件大小
* @return 默认Dimension * @return 默认Dimension
*/ */
@Override
public Dimension initEditorSize() { public Dimension initEditorSize() {
return new Dimension(500, 300); return new Dimension(500, 300);
} }
@ -150,6 +163,7 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午4:47:23 * @date 2014-11-25-下午4:47:23
* *
*/ */
@Override
protected XLayoutContainer getCreatorWrapper(String widgetName) { protected XLayoutContainer getCreatorWrapper(String widgetName) {
initStyle(); initStyle();
Dimension dimension = new Dimension(); Dimension dimension = new Dimension();
@ -201,6 +215,7 @@ public class XWCardLayout extends XLayoutContainer {
Dimension dimension = new Dimension(); Dimension dimension = new Dimension();
//放置标题的tab流式布局 //放置标题的tab流式布局
WCardTagLayout tagLayout = new WCardTagLayout("tabpane" + widgetName.replaceAll(createDefaultName(), "")); WCardTagLayout tagLayout = new WCardTagLayout("tabpane" + widgetName.replaceAll(createDefaultName(), ""));
tagLayout.setNewTab(true);
XWCardTagLayout xTag = new XWCardTagLayout(tagLayout, dimension, this); XWCardTagLayout xTag = new XWCardTagLayout(tagLayout, dimension, this);
xTag.setBackupParent(xTitle); xTag.setBackupParent(xTitle);
@ -214,25 +229,33 @@ public class XWCardLayout extends XLayoutContainer {
private XCardSwitchButton initFirstButton(String widgetName, XWCardTagLayout xTag){ private XCardSwitchButton initFirstButton(String widgetName, XWCardTagLayout xTag){
CardSwitchButton firstBtn = new CardSwitchButton(widgetName); CardSwitchButton firstBtn = new CardSwitchButton(widgetName);
firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0); firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0);
firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE));
firstBtn.setCustomStyle(true);
xTag.setCurrentCard(firstBtn); xTag.setCurrentCard(firstBtn);
XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag); XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag);
xFirstBtn.setBackupParent(xTag); xFirstBtn.setBackupParent(xTag);
return xFirstBtn; return xFirstBtn;
} }
/**
* 控件树不显示此组件
* @param path 控件树list
*/
@Override
public void notShowInComponentTree(List<Component> path) {
path.remove(LAYOUT_INDEX);
}
/** /**
* 设置父容器的名字 * 设置父容器的名字
* *
* @param parentPanel 当前父容器 * @param parentPanel 当前父容器
* @param widgetName 当前控件名 * @param widgetName 当前控件名
* *
* *
* @date 2014-11-27-上午9:47:00 * @date 2014-11-27-上午9:47:00
* *
*/ */
@Override
protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) { protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) {
parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),"")); parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),""));
} }
@ -246,7 +269,8 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午4:57:55 * @date 2014-11-25-下午4:57:55
* *
*/ */
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ @Override
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){
parentPanel.add(this, WBorderLayout.CENTER); parentPanel.add(this, WBorderLayout.CENTER);
} }
@ -259,7 +283,8 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午6:20:10 * @date 2014-11-25-下午6:20:10
* *
*/ */
public void componentAdded(ContainerEvent e) { @Override
public void componentAdded(ContainerEvent e) {
if (isRefreshing) { if (isRefreshing) {
return; return;
} }
@ -284,6 +309,7 @@ public class XWCardLayout extends XLayoutContainer {
* 是否支持标题样式 * 是否支持标题样式
* @return 默认false * @return 默认false
*/ */
@Override
public boolean hasTitleStyle() { public boolean hasTitleStyle() {
return true; return true;
} }
@ -293,6 +319,7 @@ public class XWCardLayout extends XLayoutContainer {
* @return 属性名 * @return 属性名
* @throws IntrospectionException * @throws IntrospectionException
*/ */
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
//嵌套的tab组件,内层的不支持轮播属性,屏蔽属性表 //嵌套的tab组件,内层的不支持轮播属性,屏蔽属性表
if(!isNested()) { if(!isNested()) {
@ -379,7 +406,8 @@ public class XWCardLayout extends XLayoutContainer {
} }
//初始化样式 //初始化样式
protected void initStyle() { @Override
protected void initStyle() {
LayoutBorderStyle style = toData().getBorderStyle(); LayoutBorderStyle style = toData().getBorderStyle();
initBorderTitleStyle(style); initBorderTitleStyle(style);
initBorderStyle(); initBorderStyle();
@ -432,12 +460,14 @@ public class XWCardLayout extends XLayoutContainer {
* @param designer 表单设计器 * @param designer 表单设计器
* *
*/ */
public void deleteRelatedComponent(XCreator creator,FormDesigner designer){ @Override
public void deleteRelatedComponent(XCreator creator, FormDesigner designer){
XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) creator.getBackupParent(); XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) creator.getBackupParent();
SelectionModel selectionModel = designer.getSelectionModel(); SelectionModel selectionModel = designer.getSelectionModel();
selectionModel.setSelectedCreator(mainLayout); selectionModel.setSelectedCreator(mainLayout);
selectionModel.deleteSelection(); selectionModel.deleteSelection();
} }
@Override @Override
public void setBorder(Border border) { public void setBorder(Border border) {
super.setBorder(border); super.setBorder(border);
@ -461,8 +491,22 @@ public class XWCardLayout extends XLayoutContainer {
* data属性改变触发其他操作 * data属性改变触发其他操作
* *
*/ */
@Override
public void firePropertyChange(){ public void firePropertyChange(){
initStyle(); initStyle();
} }
public void resetTabBackground(TemplateStyle templateStyle){
for (int i = 0; i < this.getXCreatorCount(); i++) {
XWTabFitLayout xCreator = (XWTabFitLayout)this.getXCreator(i);
WTabFitLayout wTabFitLayout = (WTabFitLayout)xCreator.toData();
boolean defaultStyle = ComparatorUtils.equals(templateStyle.getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE);
wTabFitLayout.setInitialBackground(defaultStyle ? null : templateStyle.getTabDefaultBackground());
wTabFitLayout.setOverBackground(null);
wTabFitLayout.setClickBackground(null);
wTabFitLayout.setCustomStyle(!defaultStyle);
xCreator.checkButonType();
}
}
} }

185
designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -3,22 +3,38 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.GraphHelper;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRCardMainBorderLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.event.Listener;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -27,9 +43,11 @@ import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
* card布局主体框架 * card布局主体框架
@ -38,17 +56,17 @@ import java.util.ArrayList;
* *
* @date: 2014-12-9-下午9:59:31 * @date: 2014-12-9-下午9:59:31
*/ */
public class XWCardMainBorderLayout extends XWBorderLayout{ public class XWCardMainBorderLayout extends XWBorderLayout {
private static final int CENTER = 1; private static final int CENTER = 1;
private static final int NORTH = 0; private static final int NORTH = 0;
public static final Color DEFAULT_BORDER_COLOR = new Color(210,210,210);
private static final int LAYOUT_INDEX = 0;
private static final int TITLE_STYLE = 2; private static final int TITLE_STYLE = 2;
private static final int NORMAL_STYLE = 1;
private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_WIDTH = 75;
private static final int EDIT_BTN_HEIGHT = 24; private static final int EDIT_BTN_HEIGHT = 20;
private static final int BORDER_WIDTH = 1;
private final int CARDMAINLAYOUT_CHILD_COUNT = 1;
/** /**
* 构造函数 * 构造函数
@ -66,6 +84,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* @date 2014-12-10-下午1:46:33 * @date 2014-12-10-下午1:46:33
* *
*/ */
@Override
public WCardMainBorderLayout toData() { public WCardMainBorderLayout toData() {
return (WCardMainBorderLayout) super.toData(); return (WCardMainBorderLayout) super.toData();
} }
@ -84,15 +103,86 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
this.add(title, position); this.add(title, position);
} }
public int getTitleWidth(){
String position = toData().getTabPosition();
if(ComparatorUtils.equals(WBorderLayout.NORTH, position) || ComparatorUtils.equals(WBorderLayout.SOUTH, position)){
return getTitlePart().getHeight();
}
return getTitlePart().getWidth();
}
public void add(Component comp, String position) { public void add(Component comp, String position) {
super.add(comp, position); super.add(comp, position);
} }
/**
* 将WLayout转换为XLayoutContainer
*/
@Override
public void convert() {
isRefreshing = true;
WBorderLayout wb = this.toData();
this.removeAll();
String[] arrs = {WBorderLayout.NORTH, WBorderLayout.SOUTH, WBorderLayout.EAST, WBorderLayout.WEST, WBorderLayout.CENTER};
for (int i = 0; i < arrs.length; i++) {
Widget wgt = wb.getLayoutWidget(arrs[i]);
//用来兼容之前titlePart设置不可见
if (wgt != null && ComparatorUtils.equals(arrs[i], WBorderLayout.NORTH) && !wgt.isVisible()) {
wgt.setVisible(true);
this.toData().setNorthSize(0);
}
if (wgt != null) {
XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(wgt, calculatePreferredSize(wgt));
this.add(comp, arrs[i]);
comp.setBackupParent(this);
}
}
dealCompatibility(wb);
isRefreshing = false;
}
private void dealCompatibility(WBorderLayout wb){
WCardMainBorderLayout ob = (WCardMainBorderLayout)wb;
WCardLayout cardLayout = ob.getCardPart();
//tab结构改变需要兼容以前的tab,重新命名tabpane
WCardTitleLayout wCardTitleLayout = ob.getTitlePart();
if(cardLayout == null || wCardTitleLayout == null){
return;
}
WCardTagLayout wCardTagLayout = wCardTitleLayout.getTagPart();
String tabpaneName = cardLayout.getWidgetName();
if (!wCardTagLayout.isNewTab()) {
wCardTagLayout.setWidgetName(tabpaneName);
LayoutBorderStyle borderStyle = cardLayout.getBorderStyle();
if(borderStyle != null){
//新tab默认都有标题
borderStyle.setType(LayoutBorderStyle.TITLE);
}
cardLayout.setWidgetName(XWCardLayout.DEFAULT_NAME + tabpaneName.replaceAll(XWCardTagLayout.DEFAULT_NAME, ""));
wCardTitleLayout.setCardName(cardLayout.getWidgetName());
wCardTagLayout.setNewTab(true);
//这边需要设置成默认值兼容之前的title高度(不知道为啥之前的title的高度会改变)
if(this.toData().getNorthSize() != 0){
ob.setNorthSize(WTitleLayout.TITLE_HEIGHT);
}
for(int i = 0 ;i < cardLayout.getListenerSize(); i ++){
Listener listener = cardLayout.getListener(i);
if(listener != null){
wCardTagLayout.addListener(listener);
}
}
cardLayout.clearListeners();
}
}
/** /**
* 切换到非添加状态 * 切换到非添加状态
* *
* @return designer 表单设计器 * @return designer 表单设计器
*/ */
@Override
public void stopAddingState(FormDesigner designer){ public void stopAddingState(FormDesigner designer){
designer.stopAddingState(); designer.stopAddingState();
return; return;
@ -119,7 +209,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
public XWCardTitleLayout getTitlePart(){ public XWCardTitleLayout getTitlePart(){
Component[] components = this.getComponents(); Component[] components = this.getComponents();
for(Component component : components){ for(Component component : components){
if(component instanceof XWCardTitleLayout){ if(component instanceof XWCardTitleLayout){
return (XWCardTitleLayout)component; return (XWCardTitleLayout)component;
} }
} }
@ -141,8 +231,14 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 控件树不显示此组件 * 控件树不显示此组件
* @param path 控件树list * @param path 控件树list
*/ */
public void notShowInComponentTree(ArrayList<Component> path) { @Override
path.remove(LAYOUT_INDEX); public void notShowInComponentTree(List<Component> path) {
return;
}
@Override
public int getShowXCreatorCount() {
return CARDMAINLAYOUT_CHILD_COUNT;
} }
@Override @Override
@ -160,7 +256,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 重新调整子组件的宽度 * 重新调整子组件的宽度
* @param width 宽度 * @param width 宽度
*/ */
public void recalculateChildWidth(int width){ @Override
public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
int size = childrenList.size(); int size = childrenList.size();
if (size > 0) { if (size > 0) {
@ -191,7 +288,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 重新调整子组件的高度 * 重新调整子组件的高度
* @param height 高度 * @param height 高度
*/ */
public void recalculateChildHeight(int height){ @Override
public void recalculateChildHeight(int height){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
int size = childrenList.size(); int size = childrenList.size();
if (size > 0) { if (size > 0) {
@ -223,6 +321,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
} }
@Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
@ -235,15 +334,19 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
//画白色的编辑层 //画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(Color.WHITE); g2d.setColor(XCreatorConstants.COVER_COLOR);
g2d.fillRect(x, y, w, h); g2d.fillRect(x, y, w, h);
//画编辑按钮所在框 //画编辑按钮所在框
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f);
g2d.setColor(XCreatorConstants.EDIT_COLOR);
g2d.setComposite(alphaComposite);
g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4);
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标 //画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH);
g2d.drawImage( g2d.drawImage(
image, image,
(x + w / 2 - 23), (x + w / 2 - 23),
@ -253,9 +356,18 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
null, null,
this this
); );
g2d.setColor(Color.BLACK); g2d.setColor(Color.WHITE);
//画编辑文字 //画编辑文字
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5);
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM);
}
}
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if (!isMouseEnter) {
super.paintBorder(g, bounds);
} }
} }
@ -265,7 +377,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* @param editingMouseListener 鼠标点击位置处理器 * @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件 * @param e 鼠标点击事件
*/ */
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ @Override
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = e.getButton() == MouseEvent.BUTTON1 && boolean isEditing = e.getButton() == MouseEvent.BUTTON1 &&
@ -289,43 +402,57 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
*/ */
@Override @Override
public XLayoutContainer getTopLayout() { public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this; return this;
} }
@Override
public int getIndexOfChild(Object child) {
XWCardTitleLayout titlePart = this.getTitlePart();
return titlePart.getIndexOfChild(child);
} }
/** /**
* data属性改变触发其他操作 * data属性改变触发其他操作
* *
*/ */
@Override
public void firePropertyChange(){ public void firePropertyChange(){
getCardPart().initStyle(); return;
} }
public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){ public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){
XWCardTitleLayout xwCardTitleLayout = getTitlePart(); XWCardTitleLayout xwCardTitleLayout = getTitlePart();
int titleSize = getTitleWidth();
xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition); xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition);
Rectangle parentBounds = new Rectangle(xwCardTitleLayout.getBounds());
switch (wTabDisplayPosition){ switch (wTabDisplayPosition){
case TOP_POSITION: case TOP_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.NORTH); this.addTitlePart(xwCardTitleLayout, WBorderLayout.NORTH);
parentBounds.height = titleSize;
break; break;
case LEFT_POSITION: case LEFT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.WEST); this.addTitlePart(xwCardTitleLayout, WBorderLayout.WEST);
parentBounds.width = titleSize;
break; break;
case BOTTOM_POSITION: case BOTTOM_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.SOUTH); this.addTitlePart(xwCardTitleLayout, WBorderLayout.SOUTH);
parentBounds.height = titleSize;
break; break;
case RIGHT_POSITION: case RIGHT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.EAST); this.addTitlePart(xwCardTitleLayout, WBorderLayout.EAST);
parentBounds.width = titleSize;
break; break;
default: default:
break; break;
} }
xwCardTitleLayout.setBounds(parentBounds);
this.addCardPart((XWCardLayout)this.getComponent(0)); this.addCardPart((XWCardLayout)this.getComponent(0));
} }
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRCardMainBorderLayoutAdapter(this);
}
} }

126
designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -25,23 +25,23 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.cardtag.DefaultTemplateStyle;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -64,7 +64,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
private static final int HEIGHT_SIDE_OFFSET = 20; private static final int HEIGHT_SIDE_OFFSET = 20;
private static final int DEFAULT_BUTTON_HEIGHT = 40; private static final int DEFAULT_VERTICAL_SPACING = 3;
public static final String DEFAULT_NAME = "tabpane";
public CardSwitchButton getCurrentCard() { public CardSwitchButton getCurrentCard() {
return currentCard; return currentCard;
@ -119,6 +121,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
* @param e 事件 * @param e 事件
* @date 2014-11-25-下午6:20:10 * @date 2014-11-25-下午6:20:10
*/ */
@Override
public void componentAdded(ContainerEvent e) { public void componentAdded(ContainerEvent e) {
super.componentAdded(e); super.componentAdded(e);
@ -136,7 +139,14 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard); WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard);
fitLayout.setTabNameIndex(getTabNameIndex()); fitLayout.setTabNameIndex(getTabNameIndex());
XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension());
WCardTagLayout layout = (WCardTagLayout) this.toData();
if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){
fitLayout.setInitialBackground(layout.getTemplateStyle().getTabDefaultBackground());
fitLayout.setCustomStyle(true);
}
tabFitLayout.setxCardSwitchButton((XCardSwitchButton)this.getComponent(0)); tabFitLayout.setxCardSwitchButton((XCardSwitchButton)this.getComponent(0));
tabFitLayout.checkButonType();
tabFitLayout.setBackupParent(cardLayout); tabFitLayout.setBackupParent(cardLayout);
cardLayout.add(tabFitLayout, widgetName); cardLayout.add(tabFitLayout, widgetName);
this.cardLayout.toData().setShowIndex(index); this.cardLayout.toData().setShowIndex(index);
@ -144,6 +154,11 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} }
@Override
protected String getIconName() {
return "tabpane.png";
}
private void initCardLayout() { private void initCardLayout() {
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent();
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent(); XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent();
@ -153,6 +168,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
/** /**
* 将WLayout转换为XLayoutContainer * 将WLayout转换为XLayoutContainer
*/ */
@Override
public void convert() { public void convert() {
isRefreshing = true; isRefreshing = true;
WCardTagLayout layout = (WCardTagLayout) this.toData(); WCardTagLayout layout = (WCardTagLayout) this.toData();
@ -169,8 +185,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
isRefreshing = false; isRefreshing = false;
} }
@Override
public String createDefaultName() { public String createDefaultName() {
return "tabpane"; return DEFAULT_NAME;
} }
/** /**
@ -178,6 +195,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
* *
* @return designer 表单设计器 * @return designer 表单设计器
*/ */
@Override
public void stopAddingState(FormDesigner designer) { public void stopAddingState(FormDesigner designer) {
designer.stopAddingState(); designer.stopAddingState();
} }
@ -212,6 +230,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
* *
* @param * @param
*/ */
@Override
public void setBorder(Border border) { public void setBorder(Border border) {
} }
@ -244,10 +263,12 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
return UIPopupMenu.EMPTY; // 不要菜单 return UIPopupMenu.EMPTY; // 不要菜单
} }
@Override
public int[] getDirections() { public int[] getDirections() {
return ((XCreator)getParent()).getDirections(); return ((XCreator)getParent()).getDirections();
} }
@Override
public Rectangle getBounds() { public Rectangle getBounds() {
return this.getParent().getBounds(); return this.getParent().getBounds();
} }
@ -257,13 +278,21 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
return this.getBackupParent().getTopLayout(); return this.getBackupParent().getTopLayout();
} }
public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(0); @Override
public int getIndexOfChild(Object child) {
XLayoutContainer cardPart = ((XWCardMainBorderLayout)this.getTopLayout()).getCardPart();
return cardPart.getIndexOfChild(child);
} }
@Override
public boolean isSupportDrag(){
return false;
}
@Override @Override
public void doLayout() { public void doLayout() {
setTabsAndAdjust();
//设置布局 //设置布局
super.doLayout(); super.doLayout();
} }
@ -304,6 +333,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
* data属性改变触发其他操作 * data属性改变触发其他操作
* *
*/ */
@Override
public void firePropertyChange() { public void firePropertyChange() {
WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData(); WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData();
((XWCardMainBorderLayout) getTopLayout()).resetTabDisplayPosition(wCardTagLayout.getDisplayPosition()); ((XWCardMainBorderLayout) getTopLayout()).resetTabDisplayPosition(wCardTagLayout.getDisplayPosition());
@ -313,77 +343,68 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
repaint(); repaint();
} }
public void setTabsAndAdjust() { public void setTabsAndAdjust() {
WCardTagLayout wCardTagLayout = (WCardTagLayout)this.toData(); WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData();
int tabLength = this.getComponentCount(); int tabLength = this.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<>(); Map<Integer, Integer> cardWidth = new HashMap<Integer, Integer>();
Map<Integer, Integer> cardHeight = new HashMap<>(); Map<Integer, Integer> cardHeight = new HashMap<Integer, Integer>();
XLayoutContainer parent = this.getBackupParent();
for (int i = 0; i < tabLength; i++) { for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
String tempText = tempCard.getText(); String tempText = tempCard.getText();
Font f = tempCard.getFont(); if (this.cardLayout == null) {
initCardLayout();
}
LayoutBorderStyle borderStyle = this.cardLayout.toData().getBorderStyle();
WidgetTitle title = borderStyle.getTitle();
FRFont f = title.getFrFont();
FontMetrics fm = GraphHelper.getFontMetrics(f); FontMetrics fm = GraphHelper.getFontMetrics(f);
switch (wCardTagLayout.getTextDirection()){ switch (wCardTagLayout.getTextDirection()) {
case TEXT_HORI_DERECTION: case TEXT_HORI_DERECTION:
cardWidth.put(i,fm.stringWidth(tempText)); cardWidth.put(i, fm.stringWidth(tempText));
cardHeight.put(i,fm.getHeight()); cardHeight.put(i, fm.getHeight());
break; break;
case TEXT_VER_DIRECTION: case TEXT_VER_DIRECTION:
int perHeight = fm.getHeight(); int perHeight = fm.getHeight();
int wordCount = tempText.length(); int wordCount = tempText.length();
if(tempText.length() !=0 ){ if (tempText.length() != 0) {
cardWidth.put(i,fm.stringWidth(tempText)/tempText.length()); cardWidth.put(i, fm.stringWidth(tempText) / tempText.length());
}else { } else {
cardWidth.put(i, 0); cardWidth.put(i, 0);
} }
cardHeight.put(i,(perHeight+3)*wordCount); cardHeight.put(i, (perHeight + DEFAULT_VERTICAL_SPACING) * wordCount);
break; break;
default: default:
break; break;
} }
} }
if(isHori()){ if (isHori()) {
adjustTabsH(tabLength, cardWidth, cardHeight); adjustTabsH(parent, tabLength, cardWidth, cardHeight);
}else { } else {
adjustTabsV(tabLength, cardWidth, cardHeight); adjustTabsV(parent, tabLength, cardWidth, cardHeight);
} }
fixTitleLayout(parent);
} }
public void adjustTabsH(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) { public void adjustTabsH(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) { if (width == null) {
return; return;
} }
int tabPaneSize = parent.getHeight();
//调整XWCardTagLayout的高度 //调整XWCardTagLayout的高度
int tempX = 0; int tempX = 0;
int maxHeight = DEFAULT_BUTTON_HEIGHT;
for (int i = 0; i < tabLength; i++) { for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds(); Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
Integer cardHeight = height.get(i)+ HEIGHT_SIDE_OFFSET ; Integer cardHeight = tabPaneSize;
if(cardHeight < DEFAULT_BUTTON_HEIGHT){
cardHeight = DEFAULT_BUTTON_HEIGHT;
}
maxHeight = maxHeight > cardHeight ? maxHeight : cardHeight ;
rectangle.setBounds(tempX, 0, cardWidth, cardHeight); rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth; tempX += cardWidth;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
setTabBtnSize(cardWidth, cardHeight, temp); 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){ public void setTabBtnSize(int cardWidth, int cardHeight, XCardSwitchButton temp){
@ -401,36 +422,27 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} }
public void adjustTabsV(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) { public void adjustTabsV(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) { if (width == null) {
return; return;
} }
int tabPaneSize = parent.getWidth();
int tempY = 0; int tempY = 0;
int maxWidth = DEFAULT_BUTTON_HEIGHT;
for (int i = 0; i < tabLength; i++) { for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds(); Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; Integer cardWidth = tabPaneSize;
maxWidth = maxWidth > cardWidth ? maxWidth : cardWidth;
//先用这边的固定高度 //先用这边的固定高度
Integer cardHeight = height.get(i) + HEIGHT_SIDE_OFFSET; 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); rectangle.setBounds(0, tempY, cardWidth, cardHeight);
tempY += cardHeight; tempY += cardHeight;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
setTabBtnSize(cardWidth, cardHeight, temp); setTabBtnSize(cardWidth, cardHeight, temp);
} }
}
private void fixTitleLayout(XLayoutContainer parent){
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); 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); LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent);
if (layoutAdapter != null) { if (layoutAdapter != null) {
parent.setBackupBound(parent.getBounds()); parent.setBackupBound(parent.getBounds());

55
designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java

@ -3,11 +3,6 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import javax.swing.border.Border;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -24,6 +19,12 @@ import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import javax.swing.border.Border;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.util.List;
/** /**
* *
* *
@ -33,6 +34,11 @@ public class XWCardTitleLayout extends XWBorderLayout {
private static final int CENTER = 1; private static final int CENTER = 1;
private static final int LAYOUT_INDEX = 0;
private static final int POSISIONT_OFFSET = 1;
/** /**
* 构造函数 * 构造函数
*/ */
@ -47,19 +53,48 @@ public class XWCardTitleLayout extends XWBorderLayout {
super(widget, initSize); super(widget, initSize);
} }
/**
* 初始化组件大小titlePart的宽高可能为0
*/
@Override
public void setInitSize(Dimension initSize){
return;
}
public WTabDisplayPosition getDisplayPosition(){ public WTabDisplayPosition getDisplayPosition(){
return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition(); return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition();
} }
/**
* 控件树不显示此组件
* @param path 控件树list
*/
@Override
public void notShowInComponentTree(List<Component> path) {
path.remove(LAYOUT_INDEX);
}
@Override
public int getIndexOfChild(Object child) {
int count = getComponentCount();
for (int i = 0; i < count; i++) {
Component comp = getComponent(i);
if (comp == child) {
return i - POSISIONT_OFFSET;
}
}
return -1;
}
/** /**
* 将WLayout转换为XLayoutContainer * 将WLayout转换为XLayoutContainer
*/ */
@Override
public void convert(){ public void convert(){
isRefreshing = true; isRefreshing = true;
WCardTitleLayout titleLayout = (WCardTitleLayout)this.toData(); WCardTitleLayout titleLayout = (WCardTitleLayout)this.toData();
this.setVisible(titleLayout.isVisible()); this.removeAll();
this.removeAll();
String[] arrs = {WBorderLayout.NORTH, WBorderLayout.SOUTH, WBorderLayout.EAST, WBorderLayout.WEST, WBorderLayout.CENTER}; String[] arrs = {WBorderLayout.NORTH, WBorderLayout.SOUTH, WBorderLayout.EAST, WBorderLayout.WEST, WBorderLayout.CENTER};
for (int i = 0; i < arrs.length; i++) { for (int i = 0; i < arrs.length; i++) {
Widget wgt = titleLayout.getLayoutWidget(arrs[i]); Widget wgt = titleLayout.getLayoutWidget(arrs[i]);
@ -139,7 +174,8 @@ public class XWCardTitleLayout extends XWBorderLayout {
* *
* @return designer 表单设计器 * @return designer 表单设计器
*/ */
public void stopAddingState(FormDesigner designer){ @Override
public void stopAddingState(FormDesigner designer){
designer.stopAddingState(); designer.stopAddingState();
return; return;
} }
@ -182,6 +218,7 @@ public class XWCardTitleLayout extends XWBorderLayout {
return this.getBackupParent().getTopLayout(); return this.getBackupParent().getTopLayout();
} }
@Override
public String createDefaultName() { public String createDefaultName() {
return "tabpane"; return "tabpane";
} }
@ -191,5 +228,5 @@ public class XWCardTitleLayout extends XWBorderLayout {
public XCreator getXCreator() { public XCreator getXCreator() {
return (XCreator)this.getComponent(1); return (XCreator)this.getComponent(1);
} }
} }

195
designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -1,7 +1,6 @@
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -23,7 +22,6 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -43,7 +41,7 @@ import java.beans.IntrospectionException;
*/ */
public class XWTabFitLayout extends XWFitLayout { public class XWTabFitLayout extends XWFitLayout {
private static final int MIN_SIZE = 1; private static final int MIN_SIZE = 0;
private static final int WIDTH_SIDE_OFFSET = 57; private static final int WIDTH_SIDE_OFFSET = 57;
@ -104,16 +102,27 @@ public class XWTabFitLayout extends XWFitLayout {
super(widget, initSize); super(widget, initSize);
} }
public WTabFitLayout getWTabFitLayout(){
return (WTabFitLayout)data;
}
@Override @Override
public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { public UIPopupMenu createPopupMenu(FormDesigner formDesigner) {
return UIPopupMenu.EMPTY; // 不要菜单 return UIPopupMenu.EMPTY; // 不要菜单
} }
@Override
protected String getIconName() {
return "tab_fit_layout.png";
}
/** /**
* 得到属性名 * 得到属性名
* @return 属性名 * @return 属性名
* @throws IntrospectionException * @throws IntrospectionException
*/ */
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
checkButonType(); checkButonType();
CRPropertyDescriptor[] crp = ((WTabFitLayout) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle(); CRPropertyDescriptor[] crp = ((WTabFitLayout) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle();
@ -205,41 +214,32 @@ public class XWTabFitLayout extends XWFitLayout {
return crPropertyDescriptors; return crPropertyDescriptors;
} }
private void checkButonType() { public void checkButonType() {
if (this.xCardSwitchButton == null) { WTabFitLayout wTabFitLayout = ((WTabFitLayout) data);
//假如为空,默认获取第一个tab的cardBtn属性 XCardSwitchButton xCardSwitchButton = this.getxCardSwitchButton();
try { if(xCardSwitchButton == null){
xCardSwitchButton = (XCardSwitchButton) ((XWCardMainBorderLayout) this.getTopLayout()).getTitlePart().getTagPart().getComponent(0); initRelateSwitchButton();
}catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage());
}
return;
} }
boolean isStyle = ((WTabFitLayout) data).isCustomStyle();
Background bg;
bg = ColorBackground.getInstance(NORMAL_GRAL);
CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData(); CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData();
boolean isStyle = wTabFitLayout.isCustomStyle();
Background initialBackground = wTabFitLayout.getInitialBackground();
Background overBackground = wTabFitLayout.getOverBackground();
Background clickBackground = wTabFitLayout.getClickBackground();
if (!isStyle) { if (!isStyle) {
this.xCardSwitchButton.setCustomStyle(false); cardSwitchButton.setCustomStyle(false);
this.xCardSwitchButton.setSelectBackground(bg);
cardSwitchButton.setInitialBackground(null); cardSwitchButton.setInitialBackground(null);
cardSwitchButton.setClickBackground(null); cardSwitchButton.setClickBackground(null);
cardSwitchButton.setOverBackground(null); cardSwitchButton.setOverBackground(null);
} else { } else {
Background initialBackground = cardSwitchButton.getInitialBackground();
bg = initialBackground == null ? bg : initialBackground;
this.xCardSwitchButton.setSelectBackground(bg);
this.xCardSwitchButton.setCustomStyle(true);
cardSwitchButton.setCustomStyle(true); cardSwitchButton.setCustomStyle(true);
if (this.initialBackground != null){ if (initialBackground != null){
this.xCardSwitchButton.setSelectBackground(this.initialBackground); cardSwitchButton.setInitialBackground(initialBackground);
cardSwitchButton.setInitialBackground(this.initialBackground);
} }
if (this.overBackground != null){ if (overBackground != null){
cardSwitchButton.setOverBackground(this.overBackground); cardSwitchButton.setOverBackground(overBackground);
} }
if (this.clickBackground != null) { if (clickBackground != null) {
cardSwitchButton.setClickBackground(this.clickBackground); cardSwitchButton.setClickBackground(clickBackground);
} }
} }
} }
@ -256,7 +256,8 @@ public class XWTabFitLayout extends XWFitLayout {
* @param designer 表单设计器 * @param designer 表单设计器
* *
*/ */
public void deleteRelatedComponent(XCreator creator,FormDesigner designer){ @Override
public void deleteRelatedComponent(XCreator creator, FormDesigner designer){
//逐层回溯找出相关的layout和对应的tab按钮 //逐层回溯找出相关的layout和对应的tab按钮
XWTabFitLayout fitLayout = (XWTabFitLayout)creator; XWTabFitLayout fitLayout = (XWTabFitLayout)creator;
WTabFitLayout fit = (WTabFitLayout) fitLayout.toData(); WTabFitLayout fit = (WTabFitLayout) fitLayout.toData();
@ -269,21 +270,22 @@ public class XWTabFitLayout extends XWFitLayout {
//放置tab按钮的tagLayout //放置tab按钮的tagLayout
XWCardTagLayout tagLayout = titleLayout.getTagPart(); XWCardTagLayout tagLayout = titleLayout.getTagPart();
WCardTagLayout tag = (WCardTagLayout) tagLayout.toData(); WCardTagLayout tag = (WCardTagLayout) tagLayout.toData();
//先删除对应的tab按钮
for(int i=0;i<tagLayout.getComponentCount();i++){
CardSwitchButton button = tag.getSwitchButton(i);
if(button.getIndex()==index){
tagLayout.remove(i);
break;
}
}
//删除整个tab布局 //删除整个tab布局
if(tag.getWidgetCount() <= MIN_SIZE){ if(tag.getWidgetCount() <= MIN_SIZE){
deleteTabLayout(mainLayout,designer); deleteTabLayout(mainLayout,designer);
return; return;
} }
//先删除对应的tab按钮
for(int i=0;i<tagLayout.getComponentCount();i++){
CardSwitchButton button = tag.getSwitchButton(i);
if(button.getIndex()==index){
tagLayout.remove(i);
break;
}
}
//刷新tab按钮和tabFitLayout的index //刷新tab按钮和tabFitLayout的index
refreshIndex(tag,cardLayout,index); refreshIndex(tag,cardLayout,index);
@ -291,7 +293,7 @@ public class XWTabFitLayout extends XWFitLayout {
} }
private void deleteTabLayout(XLayoutContainer mainLayout,FormDesigner designer){ private void deleteTabLayout(XLayoutContainer mainLayout, FormDesigner designer){
SelectionModel selectionModel = designer.getSelectionModel(); SelectionModel selectionModel = designer.getSelectionModel();
if(mainLayout != null){ if(mainLayout != null){
selectionModel.setSelectedCreator(mainLayout); selectionModel.setSelectedCreator(mainLayout);
@ -301,21 +303,21 @@ public class XWTabFitLayout extends XWFitLayout {
FormHierarchyTreePane.getInstance().refreshRoot(); FormHierarchyTreePane.getInstance().refreshRoot();
selectionModel.setSelectedCreator(designer.getRootComponent()); selectionModel.setSelectedCreator(designer.getRootComponent());
} }
private void refreshIndex(WCardTagLayout tag,XWCardLayout cardLayout,int index){ private void refreshIndex(WCardTagLayout tag, XWCardLayout cardLayout, int index) {
for(int i=0;i<tag.getWidgetCount();i++){ for (int i = 0; i < tag.getWidgetCount(); i++) {
CardSwitchButton button = tag.getSwitchButton(i); CardSwitchButton button = tag.getSwitchButton(i);
XWTabFitLayout tempFit = (XWTabFitLayout) cardLayout.getComponent(i); XWTabFitLayout tempFit = (XWTabFitLayout) cardLayout.getComponent(i);
WTabFitLayout tempFitLayout = (WTabFitLayout) tempFit.toData(); WTabFitLayout tempFitLayout = (WTabFitLayout) tempFit.toData();
int currentFitIndex = tempFitLayout.getIndex(); int currentFitIndex = tempFitLayout.getIndex();
int buttonIndex = button.getIndex(); int buttonIndex = button.getIndex();
if(buttonIndex > index){ if (buttonIndex > index) {
button.setIndex(--buttonIndex); button.setIndex(--buttonIndex);
} }
if(currentFitIndex > index){ if (currentFitIndex > index) {
tempFitLayout.setIndex(--currentFitIndex); tempFitLayout.setIndex(--currentFitIndex);
} }
} }
} }
/** /**
@ -323,7 +325,8 @@ public class XWTabFitLayout extends XWFitLayout {
* @param comp 当前组件 * @param comp 当前组件
* void * void
*/ */
public void seleteRelatedComponent(XCreator comp){ @Override
public void seleteRelatedComponent(XCreator comp){
XWTabFitLayout fitLayout = (XWTabFitLayout)comp; XWTabFitLayout fitLayout = (XWTabFitLayout)comp;
WTabFitLayout fit = (WTabFitLayout) fitLayout.toData(); WTabFitLayout fit = (WTabFitLayout) fitLayout.toData();
int index = fit.getIndex(); int index = fit.getIndex();
@ -348,7 +351,8 @@ public class XWTabFitLayout extends XWFitLayout {
* @date 2014-12-30-下午3:15:28 * @date 2014-12-30-下午3:15:28
* *
*/ */
public XLayoutContainer findNearestFit(){ @Override
public XLayoutContainer findNearestFit(){
XLayoutContainer parent = this.getBackupParent(); XLayoutContainer parent = this.getBackupParent();
return parent == null ? null : parent.findNearestFit(); return parent == null ? null : parent.findNearestFit();
} }
@ -357,6 +361,7 @@ public class XWTabFitLayout extends XWFitLayout {
* 非顶层自适应布局的缩放 * 非顶层自适应布局的缩放
* @param percent 百分比 * @param percent 百分比
*/ */
@Override
public void adjustCompSize(double percent) { public void adjustCompSize(double percent) {
this.adjustCreatorsWhileSlide(percent); this.adjustCreatorsWhileSlide(percent);
} }
@ -375,6 +380,7 @@ public class XWTabFitLayout extends XWFitLayout {
* *
* @param percent 宽度变化的百分比 * @param percent 宽度变化的百分比
*/ */
@Override
public void adjustCreatorsWidth(double percent) { public void adjustCreatorsWidth(double percent) {
if (this.getComponentCount()==0) { if (this.getComponentCount()==0) {
// 初始化没有拖入控件时,实际宽度依然调整 // 初始化没有拖入控件时,实际宽度依然调整
@ -407,6 +413,7 @@ public class XWTabFitLayout extends XWFitLayout {
* 同时调整容器内的组件们,缩小时需要考虑有的组件高度不满足缩小高度 * 同时调整容器内的组件们,缩小时需要考虑有的组件高度不满足缩小高度
* @param percent 高度变化的百分比 * @param percent 高度变化的百分比
*/ */
@Override
public void adjustCreatorsHeight(double percent) { public void adjustCreatorsHeight(double percent) {
if (this.getComponentCount()==0) { if (this.getComponentCount()==0) {
//调整高度后,wlayout那边记录下 //调整高度后,wlayout那边记录下
@ -431,6 +438,7 @@ public class XWTabFitLayout extends XWFitLayout {
LayoutUtils.layoutContainer(this); LayoutUtils.layoutContainer(this);
} }
@Override
public XLayoutContainer getOuterLayout(){ public XLayoutContainer getOuterLayout(){
XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent(); XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent();
return cardLayout.getBackupParent(); return cardLayout.getBackupParent();
@ -445,12 +453,43 @@ public class XWTabFitLayout extends XWFitLayout {
wgt.setBackupBounds(this.getComponent(m).getBounds()); wgt.setBackupBounds(this.getComponent(m).getBounds());
} }
} }
/**
* 获取其在控件树上可见父层
* @return 组件
*/
@Override
public Component getParentShow(){
XCardSwitchButton cardSwitchButton = this.getxCardSwitchButton();
if(cardSwitchButton == null){
initRelateSwitchButton();
}
//控件树上显示其taglayout层
if ((cardSwitchButton != null)) {
return cardSwitchButton.getBackupParent();
}
return super.getParentShow();
}
public void initRelateSwitchButton(){
//先确定此tabFitLayout所处位置
XLayoutContainer parentContainer = this.getBackupParent();
int index = parentContainer.getIndexOfChild(this);
XWCardMainBorderLayout cardMainBorderLayout = (XWCardMainBorderLayout) this.getTopLayout();
XWCardTitleLayout titleLayout = cardMainBorderLayout.getTitlePart();
XWCardTagLayout tagLayout = titleLayout.getTagPart();
XCreator xCreator = tagLayout.getXCreator(index);
if(xCreator != null){
this.setxCardSwitchButton((XCardSwitchButton)xCreator);
}
}
/** /**
* 去除原有的间隔 * 去除原有的间隔
* @param gap 间隔 * @param gap 间隔
*/ */
public void moveCompInterval(int gap) { @Override
public void moveCompInterval(int gap) {
if (gap == 0) { if (gap == 0) {
return; return;
} }
@ -507,7 +546,8 @@ public class XWTabFitLayout extends XWFitLayout {
* ps:改变布局大小或者拖入删除拉伸都要重新考虑间隔 * ps:改变布局大小或者拖入删除拉伸都要重新考虑间隔
* @param gap 间隔 * @param gap 间隔
*/ */
public void addCompInterval(int gap) { @Override
public void addCompInterval(int gap) {
if (gap == 0) { if (gap == 0) {
return; return;
} }
@ -552,6 +592,7 @@ public class XWTabFitLayout extends XWFitLayout {
return new WidgetPropertyUIProvider[0]; return new WidgetPropertyUIProvider[0];
} }
@Override
public void firePropertyChange(){ public void firePropertyChange(){
checkButonType(); checkButonType();
//根据字体长度设置tab宽度 //根据字体长度设置tab宽度
@ -559,24 +600,9 @@ public class XWTabFitLayout extends XWFitLayout {
XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent(); XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent();
XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent(); XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent();
XWCardTitleLayout titleLayout = mainLayout.getTitlePart(); XWCardTitleLayout titleLayout = mainLayout.getTitlePart();
// //放置tab按钮的tagLayout //放置tab按钮的tagLayout
XWCardTagLayout tagLayout = titleLayout.getTagPart(); XWCardTagLayout tagLayout = titleLayout.getTagPart();
tagLayout.setTabsAndAdjust(); tagLayout.setTabsAndAdjust();
initialBackground = ((WTabFitLayout) data).getInitialBackground();
overBackground = ((WTabFitLayout) data).getOverBackground();
clickBackground = ((WTabFitLayout)data).getClickBackground();
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
if(initialBackground != null){
xCardSwitchButton.setSelectBackground(initialBackground);
cardSwitchButton.setInitialBackground(initialBackground);
}
if(overBackground != null){
cardSwitchButton.setOverBackground(overBackground);
}
if(clickBackground != null){
cardSwitchButton.setClickBackground(clickBackground);
}
} }
public void setCardSwitchBtnSize(){ public void setCardSwitchBtnSize(){
@ -587,5 +613,26 @@ public class XWTabFitLayout extends XWFitLayout {
xCardSwitchButton.setPreferredSize(new Dimension(width, xCardSwitchButton.getHeight())); xCardSwitchButton.setPreferredSize(new Dimension(width, xCardSwitchButton.getHeight()));
} }
private void checkVisible(){
WTabFitLayout wTabFitLayout = (WTabFitLayout)this.data;
CardSwitchButton cardSwitchButton = wTabFitLayout.getCurrentCard();
cardSwitchButton.setVisible(wTabFitLayout.isVisible());
}
/**
* 是否支持设置可见
* return boolean
*/
@Override
public boolean supportSetVisible(){
return true;
}
@Override
public void resetVisible(boolean visible){
checkVisible();
}
} }

48
designer-form/src/com/fr/design/designer/properties/EventPropertyTable.java

@ -30,10 +30,10 @@ public class EventPropertyTable extends UIListControlPane {
this.designer = designer; this.designer = designer;
} }
@Override @Override
public String getAddItemText() { public String getAddItemText() {
return Inter.getLocText("FR-Designer_Add_Event"); return Inter.getLocText("FR-Designer_Add_Event");
} }
public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane { public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane {
@ -70,9 +70,9 @@ public class EventPropertyTable extends UIListControlPane {
return false; return false;
} }
} }
private String switchLang(String eventName) { private String switchLang(String eventName) {
return Inter.getLocText("Event-" + eventName); return Inter.getLocText("FR-Engine_Event_" + eventName);
} }
/** /**
@ -93,31 +93,31 @@ public class EventPropertyTable extends UIListControlPane {
refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class)); refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class));
ArrayList<NameObject> nameObjectList = new ArrayList<>(); ArrayList<NameObject> nameObjectList = new ArrayList<>();
for (int i = 0, size = widget.getListenerSize(); i < size; i++) { for (int i = 0, size = widget.getListenerSize(); i < size; i++) {
Listener listener = widget.getListener(i); Listener listener = widget.getListener(i);
if (!listener.isDefault()) { if (!listener.isDefault()) {
nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener)); nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener));
} }
} }
populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()])); populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()]));
checkButtonEnabled(); checkButtonEnabled();
this.repaint(); this.repaint();
} }
/** /**
* 更新控件事件 * 更新控件事件
* @param creator 控件 * @param creator 控件
*/ */
public void updateWidgetListener(XCreator creator) { public void updateWidgetListener(XCreator creator) {
(creator.toData()).clearListeners(); (creator.toData()).clearListeners();
Nameable[] res = this.update(); Nameable[] res = this.update();
for (int i = 0; i < res.length; i++) { for (int i = 0; i < res.length; i++) {
NameObject nameObject = (NameObject)res[i]; NameObject nameObject = (NameObject)res[i];
(creator.toData()).addListener((Listener) nameObject.getObject()); (creator.toData()).addListener((Listener) nameObject.getObject());
} }
designer.fireTargetModified(); designer.fireTargetModified();
checkButtonEnabled(); checkButtonEnabled();
} }
@ -135,9 +135,9 @@ public class EventPropertyTable extends UIListControlPane {
@Override @Override
public void saveSettings() { public void saveSettings() {
if (isPopulating) { if (isPopulating) {
return; return;
} }
updateWidgetListener(creator); updateWidgetListener(creator);
} }
} }

21
designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -1,18 +1,15 @@
package com.fr.design.designer.treeview; package com.fr.design.designer.treeview;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.Icon;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import javax.swing.Icon;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.Component;
import com.fr.design.designer.creator.XCreator; import java.awt.Dimension;
import com.fr.design.designer.creator.XCreatorUtils;
public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer { public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
@ -25,12 +22,6 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) { if (value instanceof XCreator) {
String name = ((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); setText(name);
Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value); Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value);
if (icon != null) { if (icon != null) {

25
designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java

@ -1,19 +1,22 @@
package com.fr.design.designer.treeview; package com.fr.design.designer.treeview;
import java.awt.Component; import com.fr.base.FRContext;
import java.lang.reflect.Method; import com.fr.design.designer.beans.events.DesignerEvent;
import java.util.ArrayList; 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.creator.XWidgetCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener; import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel; import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.Component;
import com.fr.base.FRContext; import java.lang.reflect.Method;
import com.fr.design.designer.creator.*; import java.util.ArrayList;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.form.ui.Widget;
public class ComponentTreeModel implements TreeModel { public class ComponentTreeModel implements TreeModel {
@ -23,6 +26,7 @@ public class ComponentTreeModel implements TreeModel {
private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1; private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1;
public ComponentTreeModel(FormDesigner designer, Component root) { public ComponentTreeModel(FormDesigner designer, Component root) {
this.designer = designer; this.designer = designer;
this.root = root; this.root = root;
@ -60,8 +64,9 @@ public class ComponentTreeModel implements TreeModel {
public int getChildCount(Object parent) { public int getChildCount(Object parent) {
if (parent != null && parent instanceof XLayoutContainer) { if (parent != null && parent instanceof XLayoutContainer) {
XLayoutContainer xlayout = (XLayoutContainer) parent; XLayoutContainer xlayout = (XLayoutContainer) parent;
return xlayout.getXCreatorCount(); return xlayout.getShowXCreatorCount();
} }
return 0; return 0;
} }

BIN
designer-form/src/com/fr/design/form/images/joption_failure.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

BIN
designer-form/src/com/fr/design/form/images/joption_success.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

7
designer-form/src/com/fr/design/form/parameter/FormParaDesigner.java

@ -13,7 +13,6 @@ import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.Action;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -21,6 +20,7 @@ import javax.swing.JPanel;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI; import com.fr.base.parameter.ParameterUI;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.actions.CopyAction; import com.fr.design.designer.beans.actions.CopyAction;
@ -107,11 +107,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA);
EastRegionContainerPane.getInstance().replaceWidgetLibPane( EastRegionContainerPane.getInstance().replaceWidgetLibPane(
FormWidgetDetailPane.getInstance(this)); FormWidgetDetailPane.getInstance(this));
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
ParameterPropertyPane parameterPropertyPane = ParameterPropertyPane.getInstance(this); ParameterPropertyPane parameterPropertyPane = ParameterPropertyPane.getInstance(this); // 传入this的同时会更新参数面板高度
parameterPropertyPane.refreshState(); parameterPropertyPane.refreshState();
EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane); EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane);
EastRegionContainerPane.getInstance().setParameterHeight(parameterPropertyPane.getPreferredSize().height);
EastRegionContainerPane.getInstance().replaceWidgetSettingsPane( EastRegionContainerPane.getInstance().replaceWidgetSettingsPane(
WidgetPropertyPane.getInstance(this)); WidgetPropertyPane.getInstance(this));
} else { } else {

10
designer-form/src/com/fr/design/form/util/XCreatorConstants.java

@ -31,7 +31,7 @@ public class XCreatorConstants {
public static final Color RESIZE_BOX_BORDER_COLOR = new Color(143, 171, 196); public static final Color RESIZE_BOX_BORDER_COLOR = new Color(143, 171, 196);
// 当前选取的组件的边框线着色 // 当前选取的组件的边框线着色
public static final Color SELECTION_COLOR = new Color(179, 209, 236); public static final Color SELECTION_COLOR = new Color(179, 209, 236);
public static final Color FORM_BORDER_COLOR = new Color(200, 201, 205); public static final Color FORM_BORDER_COLOR = new Color(141, 194, 249);
// 设计器区域外边框的颜色和粗细 // 设计器区域外边框的颜色和粗细
public static final Border AREA_BORDER = BorderFactory.createLineBorder(new Color(224, 224, 255), 0); public static final Border AREA_BORDER = BorderFactory.createLineBorder(new Color(224, 224, 255), 0);
// 布局拖拽时的颜色 // 布局拖拽时的颜色
@ -43,10 +43,14 @@ public class XCreatorConstants {
public static final Color FIT_LAYOUT_POINT_COLOR = new Color(106, 168, 222); public static final Color FIT_LAYOUT_POINT_COLOR = new Color(106, 168, 222);
// 格子布局的分割线 // 格子布局的分割线
public static final Color LAYOUT_SEP_COLOR = new Color(210, 210, 210); public static final Color LAYOUT_SEP_COLOR = new Color(210, 210, 210);
// 组件覆盖层颜色
public static final Color COVER_COLOR = new Color(216, 242, 253);
//组件编辑按钮颜色
public static final Color EDIT_COLOR = new Color(51, 51, 52);
// 伸缩表单操作条的颜色 // 伸缩表单操作条的颜色
public static final Color OP_COLOR = new Color(157,228,245); public static final Color OP_COLOR = new Color(157,228,245);
// 不同粗细的线 // 不同粗细的线
public static final BasicStroke STROKE = new BasicStroke(2); public static final BasicStroke STROKE = new BasicStroke(2);
} }

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

Loading…
Cancel
Save