Browse Source

merge

master
plough 7 years ago
parent
commit
f1dc915f1c
  1. 2
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 2
      designer-base/src/com/fr/design/actions/file/PreferencePane.java
  3. 4
      designer-base/src/com/fr/design/actions/help/WebDemoAction.java
  4. 20
      designer-base/src/com/fr/design/gui/ispinner/UISpinner.java
  5. 4
      designer-base/src/com/fr/design/gui/style/FRFontPane.java
  6. 37
      designer-base/src/com/fr/design/icon/IconPathConstants.java
  7. BIN
      designer-base/src/com/fr/design/images/control/newEdit.png
  8. 15
      designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java
  9. 14
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java
  10. 18
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java
  11. 40
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java
  12. 14
      designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  13. 5
      designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java
  14. 95
      designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java
  15. 72
      designer-base/src/com/fr/design/style/background/BackgroundFactory.java
  16. 88
      designer-base/src/com/fr/design/style/background/BackgroundTabPane.java
  17. 15
      designer-base/src/com/fr/design/utils/DesignUtils.java
  18. 24
      designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java
  19. 28
      designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java
  20. 2
      designer-base/src/com/fr/start/BBSGuestPaneProvider.java
  21. 128
      designer-base/src/com/fr/start/ServerStarter.java
  22. 34
      designer-base/src/com/fr/start/SplashStrategy.java
  23. 56
      designer-base/src/com/fr/start/TomcatFRHost.java
  24. 15
      designer-base/src/com/fr/start/server/EmbedServerEvent.java
  25. 133
      designer-base/src/com/fr/start/server/FRTomcat.java
  26. 138
      designer-base/src/com/fr/start/server/FineEmbedServer.java
  27. 62
      designer-base/src/com/fr/start/server/MultiOutputStream.java
  28. 76
      designer-base/src/com/fr/start/server/ServerManageFrame.java
  29. 144
      designer-base/src/com/fr/start/server/ServerTray.java
  30. 280
      designer-base/src/com/fr/start/server/TomcatHost.java
  31. 18
      designer-base/src/com/fr/start/server/TomcatServerListener.java
  32. 6
      designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java
  33. 16
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  34. 62
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java
  35. 9
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  36. 3
      designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java
  37. 3
      designer-form/src/com/fr/design/designer/beans/models/StateModel.java
  38. 14
      designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java
  39. 35
      designer-form/src/com/fr/design/designer/creator/XButton.java
  40. 35
      designer-form/src/com/fr/design/designer/creator/XChartEditor.java
  41. 1
      designer-form/src/com/fr/design/designer/creator/XCreator.java
  42. 3
      designer-form/src/com/fr/design/designer/creator/XCreatorTools.java
  43. 16
      designer-form/src/com/fr/design/designer/creator/XElementCase.java
  44. 15
      designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  45. 13
      designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  46. 14
      designer-form/src/com/fr/design/designer/creator/XWTitleLayout.java
  47. 7
      designer-form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java
  48. 35
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  49. 230
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  50. 54
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  51. 177
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  52. 126
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  53. 49
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  54. 159
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  55. 21
      designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  56. 25
      designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  57. 15
      designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java
  58. 5
      designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java
  59. 34
      designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java
  60. 14
      designer-form/src/com/fr/design/mainframe/ComponentTree.java
  61. 48
      designer-form/src/com/fr/design/mainframe/CoverPane.java
  62. 6
      designer-form/src/com/fr/design/mainframe/CoverReportPane.java
  63. 2
      designer-form/src/com/fr/design/mainframe/FormArea.java
  64. 4
      designer-form/src/com/fr/design/mainframe/FormDesignerUI.java
  65. 3
      designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java
  66. 43
      designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java
  67. 3
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  68. 1
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  69. 19
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java
  70. 34
      designer-form/src/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  71. 12
      designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java
  72. 57
      designer-form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  73. 5
      designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java
  74. BIN
      designer-realize/src/com/fr/design/images/splash_10.gif
  75. 21
      designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java
  76. 31
      designer-realize/src/com/fr/start/Designer.java
  77. 142
      designer-realize/src/com/fr/start/SplashContext.java
  78. 210
      designer-realize/src/com/fr/start/fx/FastGifImage.java
  79. 211
      designer-realize/src/com/fr/start/fx/PrismImageLoader2.java
  80. 60
      designer-realize/src/com/fr/start/fx/SplashFx.java
  81. 134
      designer-realize/src/com/fr/start/fx/SplashFxWindow.java
  82. 69
      designer-realize/src/com/fr/start/jni/SplashJNI.java
  83. 95
      designer-realize/src/com/fr/start/jni/SplashMac.java
  84. BIN
      designer-realize/src/com/fr/start/jni/splash.dylib
  85. 4
      designer-realize/src/com/fr/start/module/DesignerEnvProvider.java
  86. 22
      designer-realize/src/com/fr/start/module/DesignerStartup.java
  87. 1
      designer-realize/src/com/fr/start/module/PreStartActivator.java

2
designer-base/src/com/fr/design/DesignerEnvManager.java

@ -758,7 +758,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* 返回Jetty服务器的端口号 * 返回Jetty服务器的端口号
*/ */
public int getJettyServerPort() { public int getEmbedServerPort() {
return this.jettyServerPort; return this.jettyServerPort;
} }

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

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

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

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"; public static final String EDIT_ICON_PATH = "/com/fr/design/images/control/newEdit.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

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

72
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();
}
}

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

@ -9,7 +9,6 @@ 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.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,7 +28,7 @@ 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.*;
import java.awt.*; import java.awt.*;
@ -142,7 +141,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();
@ -208,15 +207,9 @@ public class DesignUtils {
break; break;
} }
} }
// 更新CurrentEnv于FRContext & DesignerEnvManager // 更新CurrentEnv于FRContext & DesignerEnvManager
FRContext.setCurrentEnv(env); FRContext.setCurrentEnv(env);
refreshDesignerFrame(env); refreshDesignerFrame(env);
// 当换了运行环境,重置服务器,让它下次预览时重启
if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) {
StartServer.currentEnvChanged();
}
} }
public static void refreshDesignerFrame(Env env) { public static void refreshDesignerFrame(Env env) {
@ -358,10 +351,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) {
// //
} }

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

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

128
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();
@ -84,56 +70,12 @@ public class StartServer {
} }
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 {
if (!tomcatHost.isStarted()) {
tomcatHost.start();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} finally {
//先访问Demo, 后访问报表, 不需要重置服务器.
NEED_LOAD_ENV = false;
browser("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName());
}
}
public static void start() {
try { try {
synchronized (lock) { FineEmbedServer.getInstance().start();
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 { } finally {
NEED_LOAD_ENV = false; //先访问Demo, 后访问报表, 不需要重置服务器.
browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName());
} }
} }
@ -143,25 +85,13 @@ public class StartServer {
* @param url 指定路径 * @param url 指定路径
*/ */
public static void browserURLWithLocalEnv(String url) { public static void browserURLWithLocalEnv(String url) {
start();
browser(url);
}
public static TomcatHost getInstance() {
// august: 正确的逻辑能保证jettyHost不为null,不然就有bug,不允许这儿加是否等于null判断
return tomcatHost;
}
/** FineEmbedServer.getInstance().start();
* 运行环境改变事件 browser(url);
*/
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;
@ -180,6 +110,7 @@ public class StartServer {
} }
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可以打开.
@ -193,29 +124,39 @@ public class StartServer {
} }
} }
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));
@ -227,6 +168,7 @@ public class StartServer {
@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);
}
}
}

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

@ -0,0 +1,138 @@
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.stable.lifecycle.AbstractLifecycle;
import com.fr.stable.lifecycle.Lifecycle;
import com.fr.stable.lifecycle.LifecycleEvent;
import com.fr.stable.lifecycle.LifecycleListener;
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 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 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 {

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

@ -1,51 +1,50 @@
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 MenuItem manangeMenu, startMenu, stopMenu, exitMenu; private static ServerTray INSTANCE;
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 MenuItem startMenu;
private TrayIcon trayIcon; private MenuItem stopMenu;
private TomcatHost hostTomcatServer; private Image trayStartedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png");
private Image trayStoppedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStopped.png");
public ServerTray(TomcatHost hostTomcatServer) { private ServerManageFrame serverManageFrame;
private TrayIcon trayIcon;
this.hostTomcatServer = hostTomcatServer;
private ServerTray() {
listen();
//p:首先构建右键菜单 //p:首先构建右键菜单
PopupMenu popup = new PopupMenu(); PopupMenu popup = new PopupMenu();
manangeMenu = new MenuItem(Inter.getLocText("Server-Open_Service_Manager")); MenuItem 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();
if (!serverManageFrame.isVisible()) {
serverManageFrame.setVisible(true); serverManageFrame.setVisible(true);
} }
serverManageFrame.toFront();//p:到第一个. serverManageFrame.toFront();//p:到第一个.
@ -53,29 +52,24 @@ public class ServerTray {
}); });
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
}
} catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage(), 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) {
}
} catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage(), exp); FRContext.getLogger().error(exp.getMessage(), exp);
} }
} }
@ -106,17 +100,17 @@ public class ServerTray {
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 {
@ -125,65 +119,32 @@ public class ServerTray {
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() {
if (hostTomcatServer != null) {
try {
if(hostTomcatServer.isStarted()) {
hostTomcatServer.exit();
}
} catch(Exception exp) {
FRContext.getLogger().error(exp.getMessage(), exp);
} }
hostTomcatServer = null; private void listen() {
}
ListenerAdaptor listenerAdaptor = new ListenerAdaptor() {
SystemTray.getSystemTray().remove(trayIcon); @Override
protected void on(Event event) {
if (JVM_EXIT_ON_TRAY_EXIT) { checkPopupMenuItemEnabled();
System.exit(0);
}
} }
};
class MyTomcatListner implements TomcatServerListener { EventDispatcher.listen(EmbedServerEvent.AfterStart, listenerAdaptor);
/** EventDispatcher.listen(EmbedServerEvent.AfterStop, listenerAdaptor);
* Started
*/
public void started(TomcatHost tomcatServer) {
checkPopupMenuItemEnabled(tomcatServer);
} }
/** private void exit() {
* Stopped
*/
public void stopped(TomcatHost tomcatServer) {
checkPopupMenuItemEnabled(tomcatServer);
}
@Override FineEmbedServer.getInstance().stop();
public void exited(TomcatHost tomcatServer) { SystemTray.getSystemTray().remove(trayIcon);
exit();
}
} }
private void checkPopupMenuItemEnabled(TomcatHost tomcatServer) { private void checkPopupMenuItemEnabled() {
try { try {
if(tomcatServer.isStarted()) { if (FineEmbedServer.getInstance().isRunning()) {
startMenu.setEnabled(false); startMenu.setEnabled(false);
stopMenu.setEnabled(true); stopMenu.setEnabled(true);
@ -204,4 +165,9 @@ public class ServerTray {
} }
} }
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");
} }
} }

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,11 +197,15 @@ 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) {
super.paintComponent(g); super.paintComponent(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属性改变触发其他操作
* *

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

@ -76,6 +76,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
add(editor, BorderLayout.CENTER); add(editor, BorderLayout.CENTER);
} }
setInitSize(initSize); setInitSize(initSize);
this.setPreferredSize(initSize); this.setPreferredSize(initSize);
this.setSize(initSize); this.setSize(initSize);

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

@ -4,7 +4,6 @@
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; import java.util.List;
/** /**
@ -19,7 +18,6 @@ public interface XCreatorTools {
* @param path 控件树list * @param path 控件树list
*/ */
void notShowInComponentTree(List<Component> path); void notShowInComponentTree(List<Component> path);
/** /**
* 重置组件的名称 * 重置组件的名称
* @param name 名称 * @param name 名称
@ -61,5 +59,4 @@ public interface XCreatorTools {
* @return 组件 * @return 组件
*/ */
Component getParentShow(); 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 尺寸

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

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

@ -33,14 +33,23 @@ import com.fr.general.Inter;
import com.fr.share.ShareConstants; import com.fr.share.ShareConstants;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import java.awt.*; 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;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import javax.swing.Icon;
/** /**
* @author richer * @author richer

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;

35
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,24 +16,22 @@ 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");
@ -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,6 +124,7 @@ public class XCardAddButton extends XButton{
this.cardLayout = borderLayout.getCardPart(); this.cardLayout = borderLayout.getCardPart();
} }
@Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
@ -133,7 +132,9 @@ public class XCardAddButton extends XButton{
} }
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;

230
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,7 +125,6 @@ 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,
@ -144,6 +143,7 @@ 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();
@ -151,12 +151,11 @@ public class XCardSwitchButton extends XButton {
//关闭重新打开,相关的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,8 +166,7 @@ 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();
@ -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();
} }
@ -282,35 +280,37 @@ public class XCardSwitchButton extends XButton {
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);
} }
} }
@Override
public void paintComponent(Graphics g) { 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);
}
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); 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);
}else if (button.isShowButton() && selectBackground == null){
background = ColorBackground.getInstance(CHOOSED_GRAL);
this.setContentBackground(background);
} else {
this.setContentBackground(background);
} }
private WidgetTitle getWidgetTitle() {
if (this.cardLayout == null) {
initRelateLayout();
} }
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);
}
}
}
} }

54
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,6 +100,7 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午6:22:17 * @date 2014-11-25-下午6:22:17
* *
*/ */
@Override
public WCardLayout toData() { 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,15 +229,22 @@ 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);
}
/** /**
* 设置父容器的名字 * 设置父容器的名字
* *
@ -233,6 +255,7 @@ public class XWCardLayout extends XLayoutContainer {
* @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,6 +269,7 @@ public class XWCardLayout extends XLayoutContainer {
* @date 2014-11-25-下午4:57:55 * @date 2014-11-25-下午4:57:55
* *
*/ */
@Override
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){
parentPanel.add(this, WBorderLayout.CENTER); parentPanel.add(this, WBorderLayout.CENTER);
} }
@ -259,6 +283,7 @@ public class XWCardLayout extends XLayoutContainer {
* @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) {
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,6 +406,7 @@ public class XWCardLayout extends XLayoutContainer {
} }
//初始化样式 //初始化样式
@Override
protected void initStyle() { protected void initStyle() {
LayoutBorderStyle style = toData().getBorderStyle(); LayoutBorderStyle style = toData().getBorderStyle();
initBorderTitleStyle(style); initBorderTitleStyle(style);
@ -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();
}
}
} }

177
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;
@ -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,6 +256,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 重新调整子组件的宽度 * 重新调整子组件的宽度
* @param width 宽度 * @param width 宽度
*/ */
@Override
public void recalculateChildWidth(int width){ public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
int size = childrenList.size(); int size = childrenList.size();
@ -191,6 +288,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 重新调整子组件的高度 * 重新调整子组件的高度
* @param height 高度 * @param height 高度
*/ */
@Override
public void recalculateChildHeight(int height){ public void recalculateChildHeight(int height){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
int size = childrenList.size(); int size = childrenList.size();
@ -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());

49
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,18 +53,47 @@ 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++) {
@ -139,6 +174,7 @@ public class XWCardTitleLayout extends XWBorderLayout {
* *
* @return designer 表单设计器 * @return designer 表单设计器
*/ */
@Override
public void stopAddingState(FormDesigner designer){ 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";
} }

159
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();
@ -270,12 +271,6 @@ public class XWTabFitLayout extends XWFitLayout {
XWCardTagLayout tagLayout = titleLayout.getTagPart(); XWCardTagLayout tagLayout = titleLayout.getTagPart();
WCardTagLayout tag = (WCardTagLayout) tagLayout.toData(); WCardTagLayout tag = (WCardTagLayout) tagLayout.toData();
//删除整个tab布局
if(tag.getWidgetCount() <= MIN_SIZE){
deleteTabLayout(mainLayout,designer);
return;
}
//先删除对应的tab按钮 //先删除对应的tab按钮
for(int i=0;i<tagLayout.getComponentCount();i++){ for(int i=0;i<tagLayout.getComponentCount();i++){
CardSwitchButton button = tag.getSwitchButton(i); CardSwitchButton button = tag.getSwitchButton(i);
@ -284,6 +279,13 @@ public class XWTabFitLayout extends XWFitLayout {
break; break;
} }
} }
//删除整个tab布局
if(tag.getWidgetCount() <= MIN_SIZE){
deleteTabLayout(mainLayout,designer);
return;
}
//刷新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);
@ -302,17 +304,17 @@ public class XWTabFitLayout extends XWFitLayout {
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,6 +325,7 @@ public class XWTabFitLayout extends XWFitLayout {
* @param comp 当前组件 * @param comp 当前组件
* void * void
*/ */
@Override
public void seleteRelatedComponent(XCreator comp){ public void seleteRelatedComponent(XCreator comp){
XWTabFitLayout fitLayout = (XWTabFitLayout)comp; XWTabFitLayout fitLayout = (XWTabFitLayout)comp;
WTabFitLayout fit = (WTabFitLayout) fitLayout.toData(); WTabFitLayout fit = (WTabFitLayout) fitLayout.toData();
@ -348,6 +351,7 @@ public class XWTabFitLayout extends XWFitLayout {
* @date 2014-12-30-下午3:15:28 * @date 2014-12-30-下午3:15:28
* *
*/ */
@Override
public XLayoutContainer findNearestFit(){ 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();
@ -446,10 +454,41 @@ public class XWTabFitLayout extends XWFitLayout {
} }
} }
/**
* 获取其在控件树上可见父层
* @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 间隔
*/ */
@Override
public void moveCompInterval(int gap) { public void moveCompInterval(int gap) {
if (gap == 0) { if (gap == 0) {
return; return;
@ -507,6 +546,7 @@ public class XWTabFitLayout extends XWFitLayout {
* ps:改变布局大小或者拖入删除拉伸都要重新考虑间隔 * ps:改变布局大小或者拖入删除拉伸都要重新考虑间隔
* @param gap 间隔 * @param gap 间隔
*/ */
@Override
public void addCompInterval(int gap) { 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();
}
} }

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

15
designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java

@ -3,11 +3,6 @@
*/ */
package com.fr.design.gui.xpane; package com.fr.design.gui.xpane;
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
@ -21,6 +16,11 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/** /**
* CardTagLayoutBorderPane Pane. * CardTagLayoutBorderPane Pane.
*/ */
@ -94,11 +94,14 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
public LayoutBorderStyle update() { public LayoutBorderStyle update() {
LayoutBorderStyle style = new LayoutBorderStyle(); LayoutBorderStyle style = new LayoutBorderStyle();
if (this.getBorderStyle() != null) {
style.setStyle(this.getBorderStyle());
}
style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex()); style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex());
style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle()); style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle());
style.setColor(this.getCurrentLineColorPane().getColor()); style.setColor(this.getCurrentLineColorPane().getColor());
style.setBackground(this.getBackgroundPane().update()); style.setBackground(this.getBackgroundPane().update());
style.setAlpha((float)(this.getNumberDragPane().updateBean()/this.getMaxNumber())); style.setAlpha((float) (this.getNumberDragPane().updateBean() / this.getMaxNumber()));
return style; return style;
} }

5
designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java

@ -11,4 +11,9 @@ public class CardTagLayoutBorderPreviewPane extends LayoutBorderPreviewPane{
public CardTagLayoutBorderPreviewPane(LayoutBorderStyle borderStyle) { public CardTagLayoutBorderPreviewPane(LayoutBorderStyle borderStyle) {
super(borderStyle,true); super(borderStyle,true);
} }
@Override
protected void showTitlePreviewPane(){
}
} }

34
designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java

@ -13,10 +13,13 @@ import com.fr.general.FRFont;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.Color;
import java.awt.*; import java.awt.Dimension;
import java.awt.geom.Rectangle2D; import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D.Double; import java.awt.geom.Rectangle2D.Double;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
@ -54,7 +57,7 @@ public class LayoutBorderPreviewPane extends JPanel{
add(jp); add(jp);
} }
public LayoutBorderPreviewPane(LayoutBorderStyle borderStyle,boolean isTabLayout) { public LayoutBorderPreviewPane(LayoutBorderStyle borderStyle, boolean isTabLayout) {
this(borderStyle); this(borderStyle);
this.isTabLayout = true; this.isTabLayout = true;
} }
@ -74,7 +77,7 @@ public class LayoutBorderPreviewPane extends JPanel{
Background background = borderStyle.getBackground(); Background background = borderStyle.getBackground();
if (background != null) { if (background != null) {
Shape shape = new Rectangle2D.Double(smallGAP, smallGAP, this.getWidth() - GAP, this.getHeight() - GAP); Shape shape = new Double(smallGAP, smallGAP, this.getWidth() - GAP, this.getHeight() - GAP);
background.paint(g, shape); background.paint(g, shape);
} else { } else {
g.setColor(Color.WHITE); g.setColor(Color.WHITE);
@ -90,13 +93,16 @@ public class LayoutBorderPreviewPane extends JPanel{
int height = borderStyle.getTitle().getFrFont().getSize() + GAP; int height = borderStyle.getTitle().getFrFont().getSize() + GAP;
jp.setPreferredSize(new Dimension(getWidth() - GAP, height)); jp.setPreferredSize(new Dimension(getWidth() - GAP, height));
jp.setBounds(smallGAP,smallGAP, getWidth() - GAP, height); jp.setBounds(smallGAP,smallGAP, getWidth() - GAP, height);
borderStyle.paint(g, new Rectangle2D.Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP)); borderStyle.paint(g, new Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP));
jp.setFontObject(borderStyle.getTitle().getFrFont()); jp.setFontObject(borderStyle.getTitle().getFrFont());
jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE); showTitlePreviewPane();
} }
} }
protected void showTitlePreviewPane(){
jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE);
}
private class titlePreviewPane extends UITextArea { private class titlePreviewPane extends UITextArea {
private FRFont frFont = null; private FRFont frFont = null;
@ -134,7 +140,7 @@ public class LayoutBorderPreviewPane extends JPanel{
} }
Background background = title.getBackground(); Background background = title.getBackground();
if (background != null) { if (background != null) {
Shape shape = new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight()); Shape shape = new Double(0, 0, this.getWidth(), this.getHeight());
background.paint(g, shape); background.paint(g, shape);
} }
GraphHelper.drawString(g2d, paintText, startX1, startY); GraphHelper.drawString(g2d, paintText, startX1, startY);
@ -145,25 +151,25 @@ public class LayoutBorderPreviewPane extends JPanel{
} }
g.setColor(borderStyle.getColor()); g.setColor(borderStyle.getColor());
int line = GraphHelper.getLineStyleSize(borderStyle.getBorder()); int line = GraphHelper.getLineStyleSize(borderStyle.getBorder());
Double double1 = new Rectangle2D.Double(0, getHeight()-1, getWidth(), getHeight()); Double double1 = new Double(0, getHeight()-1, getWidth(), getHeight());
double x = double1.getX() + (line == 1 ? 1 : 2) - line - 1; double x = double1.getX() + (line == 1 ? 1 : 2) - line - 1;
double y = double1.getY() + (line == 1 ? 1 : 2) - line ; double y = double1.getY() + (line == 1 ? 1 : 2) - line ;
RoundRectangle2D.Double double2 = new RoundRectangle2D.Double(x, y, double1.getWidth() + line, double1.getHeight() + line, 0, 0); RoundRectangle2D.Double double2 = new RoundRectangle2D.Double(x, y, double1.getWidth() + line, double1.getHeight() + line, 0, 0);
GraphHelper.draw(g,double2, borderStyle.getBorder()); GraphHelper.draw(g,double2, borderStyle.getBorder());
} }
private void drawTabBack(Graphics2D g2d,Graphics g,WidgetTitle title,FontMetrics fm,int startX1,int startY){ private void drawTabBack(Graphics2D g2d, Graphics g, WidgetTitle title, FontMetrics fm, int startX1, int startY){
Dimension d = getSize(); Dimension d = getSize();
String paintText = Inter.getLocText("FR-Designer_Title")+TAB_ZERO; String paintText = Inter.getLocText("FR-Designer_Title")+TAB_ZERO;
Background rightBack = ColorBackground.getInstance(XCardSwitchButton.CHOOSED_GRAL); Background rightBack = ColorBackground.getInstance(XCardSwitchButton.CHOOSED_GRAL);
Shape right = new Rectangle2D.Double(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight()); Shape right = new Double(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight());
rightBack.paint(g, right); rightBack.paint(g, right);
String rightLabel = Inter.getLocText("FR-Designer_Title")+TAB_ONE; String rightLabel = Inter.getLocText("FR-Designer_Title")+TAB_ONE;
GraphHelper.drawString(g2d, rightLabel, (d.width/2 - fm.stringWidth(paintText)) / 2+d.width/2, startY); GraphHelper.drawString(g2d, rightLabel, (d.width/2 - fm.stringWidth(paintText)) / 2+d.width/2, startY);
Background background = title.getBackground(); Background background = title.getBackground();
if (background != null) { if (background != null) {
Shape shape = new Rectangle2D.Double(0, 0, this.getWidth()/2, this.getHeight()); Shape shape = new Double(0, 0, this.getWidth()/2, this.getHeight());
background.paint(g, shape); background.paint(g, shape);
} }
GraphHelper.drawString(g2d, paintText, startX1, startY); GraphHelper.drawString(g2d, paintText, startX1, startY);

14
designer-form/src/com/fr/design/mainframe/ComponentTree.java

@ -227,21 +227,13 @@ public class ComponentTree extends JTree {
if (creator != comp) { if (creator != comp) {
creator.notShowInComponentTree(path); creator.notShowInComponentTree(path);
} }
//绝对布局作为body的时候不显示自适应布局父层 parent = creator.getParentShow();
if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) {
if ((parent.getParent() != null)
&& ((XCreator) parent.getParent()).acceptType(XWFitLayout.class)) {
parent = parent.getParent().getParent();
continue;
}
}
parent = parent.getParent();
} }
Object[] components = path.toArray(); Object[] components = path.toArray();
return new TreePath(components); return new TreePath(components);
} }
private void popupPreviewPane(int popupPosYOnScreen, XCreator comp) { private void popupPreviewPane(int popupPosYOnScreen, XCreator comp) {
if (previewPane == null) { if (previewPane == null) {
previewPane = new PopupPreviewPane(); previewPane = new PopupPreviewPane();
@ -250,7 +242,7 @@ public class ComponentTree extends JTree {
previewPane.setVisible(false); previewPane.setVisible(false);
} }
if (!previewPane.isVisible()) { if (!previewPane.isVisible() && comp.getWidth() != 0 && comp.getHeight() != 0) {
previewPane.setComp(comp); previewPane.setComp(comp);
int popupPosY = popupPosYOnScreen - FormHierarchyTreePane.getInstance().getLocationOnScreen().y; int popupPosY = popupPosYOnScreen - FormHierarchyTreePane.getInstance().getLocationOnScreen().y;
GUICoreUtils.showPopupMenu(previewPane, FormHierarchyTreePane.getInstance(), -previewPane.getPreferredSize().width, popupPosY); GUICoreUtils.showPopupMenu(previewPane, FormHierarchyTreePane.getInstance(), -previewPane.getPreferredSize().width, popupPosY);

48
designer-form/src/com/fr/design/mainframe/CoverPane.java

@ -1,12 +1,26 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.GraphHelper;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
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 javax.swing.JPanel;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import javax.swing.*;
import java.awt.*;
/** /**
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -17,14 +31,18 @@ import java.awt.*;
public class CoverPane extends JPanel { public class CoverPane extends JPanel {
private UIButton editButton; private UIButton editButton;
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
private static final int BORDER_WIDTH = 2;
private static final Color COVER_COLOR = new Color(216, 242, 253);
private static final int EDIT_BTN_WIDTH = 75;
private static final int EDIT_BTN_HEIGHT = 20;
public CoverPane() { public CoverPane() {
setLayout(getCoverLayout()); setLayout(getCoverLayout());
setBackground(null); setBackground(null);
setOpaque(false); setOpaque(false);
editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) { editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.EDIT_ICON_PATH)) {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(60, 24); return new Dimension(60, 24);
@ -32,7 +50,7 @@ public class CoverPane extends JPanel {
}; };
editButton.setBorderPainted(false); editButton.setBorderPainted(false);
editButton.setExtraPainted(false); editButton.setExtraPainted(false);
editButton.setBackground(new Color(176, 196, 222)); editButton.setForeground(Color.WHITE);
add(editButton); add(editButton);
} }
@ -86,12 +104,30 @@ public class CoverPane extends JPanel {
public void paint(Graphics g) { public void paint(Graphics g) {
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
g2d.setComposite(composite); g2d.setComposite(composite);
g2d.setColor(Color.WHITE); g2d.setColor(COVER_COLOR);
g2d.fillRect(0, 0, getWidth(), getHeight()); g2d.fillRect(0, 0, getWidth(), getHeight());
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
g2d.setColor(XCreatorConstants.EDIT_COLOR);
boolean editHover = formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR;
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, editHover ? 0.9f : 0.7f);
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);
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
GraphHelper.draw(g, getPaintBorderBounds(), Constants.LINE_MEDIUM);
super.paint(g); super.paint(g);
} }
protected Rectangle getPaintBorderBounds(){
return new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2 , getHeight() - BORDER_WIDTH * 2);
}
} }

6
designer-form/src/com/fr/design/mainframe/CoverReportPane.java

@ -21,6 +21,7 @@ import java.awt.event.WindowEvent;
* Time: 11:32 * Time: 11:32
*/ */
public class CoverReportPane extends CoverPane implements HelpDialogHandler{ public class CoverReportPane extends CoverPane implements HelpDialogHandler{
private static final int BORDER_WIDTH = 1;
private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
private JComponent controlButton = new JComponent() { private JComponent controlButton = new JComponent() {
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
@ -126,6 +127,11 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{
} }
} }
@Override
protected Rectangle getPaintBorderBounds(){
return new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - 3 * BORDER_WIDTH , getHeight() - 3 * BORDER_WIDTH);
}
@Override @Override
public void setVisible(boolean aFlag) { public void setVisible(boolean aFlag) {
super.setVisible(aFlag); super.setVisible(aFlag);

2
designer-form/src/com/fr/design/mainframe/FormArea.java

@ -507,7 +507,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
public void scrollPathToVisible(XCreator creator) { public void scrollPathToVisible(XCreator creator) {
creator.seleteRelatedComponent(creator); creator.seleteRelatedComponent(creator);
if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator) && (creator.toData()).isVisible()) { if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator)) {
designer.makeVisible(creator); designer.makeVisible(creator);
} }

4
designer-form/src/com/fr/design/mainframe/FormDesignerUI.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@ -266,6 +267,7 @@ public class FormDesignerUI extends ComponentUI {
bounds.y -= designer.getArea().getVerticalValue(); bounds.y -= designer.getArea().getVerticalValue();
drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height);
//选中时边框颜色
g.setColor(XCreatorConstants.FORM_BORDER_COLOR); g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
@ -277,7 +279,7 @@ public class FormDesignerUI extends ComponentUI {
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
resetCreatorBounds(creatorBounds); resetCreatorBounds(creatorBounds);
} }
GraphHelper.draw(g, creatorBounds, Constants.LINE_MEDIUM); creator.paintBorder(g, creatorBounds);
} }
} }

3
designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java

@ -9,9 +9,8 @@ import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import javax.swing.*; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;

43
designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java

@ -1,6 +1,7 @@
package com.fr.design.widget.ui.designer.component; package com.fr.design.widget.ui.designer.component;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.widget.accessibles.AccessibleTabBackgroundEditor;
import com.fr.design.widget.component.BackgroundCompPane; import com.fr.design.widget.component.BackgroundCompPane;
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;
@ -15,33 +16,47 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane<WTabFitLayout
} }
public void update(WTabFitLayout wTabFitLayout){ @Override
protected void initBackgroundEditor(){
initialBackgroundEditor = new AccessibleTabBackgroundEditor();
overBackgroundEditor = new AccessibleTabBackgroundEditor();
clickBackgroundEditor = new AccessibleTabBackgroundEditor();
}
@Override
protected UILabel getClickLabel(){
return new UILabel(Inter.getLocText("FR-Designer_Background_Select"));
}
@Override
public void update(WTabFitLayout tabFitLayout){
int selectIndex = backgroundHead.getSelectedIndex(); int selectIndex = backgroundHead.getSelectedIndex();
if(selectIndex == 0){ if(selectIndex == 0){
wTabFitLayout.setCustomStyle(false); tabFitLayout.setCustomStyle(false);
wTabFitLayout.setInitialBackground(null); tabFitLayout.setInitialBackground(null);
wTabFitLayout.setOverBackground(null); tabFitLayout.setOverBackground(null);
wTabFitLayout.setClickBackground(null); tabFitLayout.setClickBackground(null);
}else{ }else{
wTabFitLayout.setCustomStyle(true); tabFitLayout.setCustomStyle(true);
wTabFitLayout.setInitialBackground((Background) initialBackgroundEditor.getValue()); tabFitLayout.setInitialBackground((Background) initialBackgroundEditor.getValue());
wTabFitLayout.setOverBackground((Background) overBackgroundEditor.getValue()); tabFitLayout.setOverBackground((Background) overBackgroundEditor.getValue());
wTabFitLayout.setClickBackground((Background)clickBackgroundEditor.getValue()); tabFitLayout.setClickBackground((Background)clickBackgroundEditor.getValue());
} }
switchCard(); switchCard();
} }
public void populate(WTabFitLayout wTabFitLayout){ @Override
if(!wTabFitLayout.isCustomStyle()){ public void populate(WTabFitLayout tabFitLayout){
if(!tabFitLayout.isCustomStyle()){
backgroundHead.setSelectedIndex(0); backgroundHead.setSelectedIndex(0);
initialBackgroundEditor.setValue(null); initialBackgroundEditor.setValue(null);
overBackgroundEditor.setValue(null); overBackgroundEditor.setValue(null);
clickBackgroundEditor.setValue(null); clickBackgroundEditor.setValue(null);
}else{ }else{
backgroundHead.setSelectedIndex(1); backgroundHead.setSelectedIndex(1);
initialBackgroundEditor.setValue(wTabFitLayout.getInitialBackground()); initialBackgroundEditor.setValue(tabFitLayout.getInitialBackground());
overBackgroundEditor.setValue(wTabFitLayout.getOverBackground()); overBackgroundEditor.setValue(tabFitLayout.getOverBackground());
clickBackgroundEditor.setValue(wTabFitLayout.getClickBackground()); clickBackgroundEditor.setValue(tabFitLayout.getClickBackground());
} }
switchCard(); switchCard();
} }

3
designer-form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java

@ -59,13 +59,14 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
@Override @Override
public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){ public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){
bounds.width = w; bounds.width = w;
creator.setBounds(bounds);
} }
@Override @Override
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){ public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){
bounds.height = h; bounds.height = h;
creator.setBounds(bounds);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "absoluteBound"; return "absoluteBound";

1
designer-form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -96,7 +96,6 @@ public class WidgetBoundPane extends BasicPane {
if (bounds.height != h) { if (bounds.height != h) {
limitHeight(wabs, h, bounds, rec); limitHeight(wabs, h, bounds, rec);
} }
creator.setBounds(bounds);
} }

19
designer-form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java

@ -3,6 +3,7 @@ package com.fr.design.widget.ui.designer.component;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
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.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
@ -12,6 +13,7 @@ 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 javax.swing.JOptionPane;
import java.awt.Rectangle; import java.awt.Rectangle;
/** /**
@ -41,10 +43,21 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane {
WCardTagLayout tagLayout = (WCardTagLayout)creator.toData(); WCardTagLayout tagLayout = (WCardTagLayout)creator.toData();
WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition(); WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition();
if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ int size = (int)cardTagWidth.getValue();
parentBounds.height = (int)cardTagWidth.getValue(); XLayoutContainer tabLayout = creator.getTopLayout();
Rectangle rectangle = tabLayout.getBounds();
if(ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){
if(rectangle.height < size){
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds"));
return;
}
parentBounds.height = size;
}else{ }else{
parentBounds.width = (int)cardTagWidth.getValue(); if(rectangle.width < size){
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds"));
return;
}
parentBounds.width = size;
} }
parent.setBounds(parentBounds); parent.setBounds(parentBounds);

34
designer-form/src/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -1,7 +1,5 @@
package com.fr.design.widget.ui.designer.layout; package com.fr.design.widget.ui.designer.layout;
import com.fr.base.io.IOFile;
import com.fr.base.iofileattr.WatermarkAttr;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -22,7 +20,6 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
@ -32,9 +29,9 @@ import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
import com.fr.log.FineLoggerFactory; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
@ -54,7 +51,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
private UISpinner componentIntervel; private UISpinner componentIntervel;
private PaddingBoundPane paddingBound; private PaddingBoundPane paddingBound;
private AccessibleWLayoutBorderStyleEditor stylePane; private AccessibleWLayoutBorderStyleEditor stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
public FRFitLayoutDefinePane(XCreator xCreator) { public FRFitLayoutDefinePane(XCreator xCreator) {
super(xCreator); super(xCreator);
@ -76,13 +72,9 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
public JPanel createAdvancePane() { public JPanel createAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new AccessibleWLayoutBorderStyleEditor(); stylePane = new AccessibleWLayoutBorderStyleEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
paddingBound = new PaddingBoundPane(); paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane( JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), stylePane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), stylePane},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
jPanel.add(paddingBound, BorderLayout.CENTER); jPanel.add(paddingBound, BorderLayout.CENTER);
jPanel.add(jp2, BorderLayout.NORTH); jPanel.add(jp2, BorderLayout.NORTH);
@ -143,7 +135,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
adaptComboBox.setSelectedIndex(ob.getCompState()); adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval()); componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle()); stylePane.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ReportUtils.getWatermarkFromAttrMarkFile(getCurrentIOFile()));
} }
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) { private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
@ -158,12 +149,13 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
@Override @Override
public WFitLayout updateBean() { public WFitLayout updateBean() {
WFitLayout layout = (WFitLayout) creator.toData(); WFitLayout layout = (WFitLayout) creator.toData();
if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) {
paddingBound.update(layout); paddingBound.update(layout);
}
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue(); LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
if(borderStyle != null){ if(borderStyle != null){
layout.setBorderStyle(borderStyle); layout.setBorderStyle(borderStyle);
} }
updateWatermark();
Item item = (Item) layoutComboBox.getSelectedItem(); Item item = (Item) layoutComboBox.getSelectedItem();
Object value = item.getValue(); Object value = item.getValue();
int state = 0; int state = 0;
@ -195,7 +187,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout}));
} }
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
//todo 验证下 //todo 验证下
@ -211,18 +203,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
return layout; return layout;
} }
private void updateWatermark() {
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue();
if (watermark != null) {
IOFile ioFile = getCurrentIOFile();
ioFile.addAttrMark(watermark);
}
}
private IOFile getCurrentIOFile() {
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
}
private void setLayoutGap(int value) { private void setLayoutGap(int value) {
int interval = wFitLayout.getCompInterval(); int interval = wFitLayout.getCompInterval();
if (value != interval) { if (value != interval) {

12
designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java

@ -38,7 +38,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
carouselInterval = new UISpinner(0, 20, 1, 0); carouselInterval = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor(); accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor();
JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
@ -51,7 +51,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel")); setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel"));
IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{
new UILabel(Inter.getLocText("FR-Designer_carouselInterval")), carouselInterval}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); new UILabel(Inter.getLocText("FR-Designer_carouselInterval")), carouselInterval}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
IntervalPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); IntervalPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6));
jPanel.add(setCarousel, BorderLayout.NORTH); jPanel.add(setCarousel, BorderLayout.NORTH);
jPanel.add(IntervalPane, BorderLayout.CENTER); jPanel.add(IntervalPane, BorderLayout.CENTER);
setCarousel.addActionListener(new ActionListener() { setCarousel.addActionListener(new ActionListener() {
@ -73,9 +73,9 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
@Override @Override
public void populateBean(WCardMainBorderLayout ob) { public void populateBean(WCardMainBorderLayout ob) {
WCardLayout cardLayout = ob.getCardPart(); WCardLayout cardLayout = ob.getCardPart();
accessibleCardTagWLayoutBorderStyleEditor.setValue(ob.getBorderStyle()); accessibleCardTagWLayoutBorderStyleEditor.setValue(cardLayout.getBorderStyle());
setCarousel.setSelected(cardLayout.isCarousel()); setCarousel.setSelected(cardLayout.isCarousel());
IntervalPane.setVisible(ob.isCarousel()); IntervalPane.setVisible(cardLayout.isCarousel());
carouselInterval.setValue(cardLayout.getCarouselInterval()); carouselInterval.setValue(cardLayout.getCarouselInterval());
} }
@ -83,10 +83,10 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
@Override @Override
public WCardMainBorderLayout updateBean() { public WCardMainBorderLayout updateBean() {
WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData(); WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData();
layout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
WCardLayout wCardLayout = layout.getCardPart(); WCardLayout wCardLayout = layout.getCardPart();
wCardLayout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
wCardLayout.setCarousel(setCarousel.isSelected()); wCardLayout.setCarousel(setCarousel.isSelected());
wCardLayout.setCarouselInterval((int)carouselInterval.getValue()); wCardLayout.setCarouselInterval(carouselInterval.getValue());
return layout; return layout;
} }
} }

57
designer-form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java

@ -1,9 +1,10 @@
package com.fr.design.widget.ui.designer.layout; package com.fr.design.widget.ui.designer.layout;
import com.fr.general.cardtag.TemplateStyle; import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
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;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
@ -12,7 +13,7 @@ import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleImgBackgroundEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleTabPaneBackgroundEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor;
import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
@ -20,8 +21,10 @@ import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.WTabTextDirection; import com.fr.form.ui.container.WTabTextDirection;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.Background; import com.fr.general.Background;
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 javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -33,7 +36,7 @@ import java.awt.Component;
* Created by kerry on 2017/11/16. * Created by kerry on 2017/11/16.
*/ */
public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout> { public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout> {
private AccessibleImgBackgroundEditor backgroundEditor; private AccessibleTabPaneBackgroundEditor backgroundEditor;
private FRFontPane frFontPane; private FRFontPane frFontPane;
private UIButtonGroup displayPositionGroup; private UIButtonGroup displayPositionGroup;
private UIButtonGroup textDirectionGroup; private UIButtonGroup textDirectionGroup;
@ -47,7 +50,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
backgroundEditor = new AccessibleImgBackgroundEditor(); backgroundEditor = new AccessibleTabPaneBackgroundEditor();
templateStyleEditor = new AccessibleTemplateStyleEditor(); templateStyleEditor = new AccessibleTemplateStyleEditor();
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
@ -57,8 +60,27 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font")); UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font"));
fontLabel.setVerticalAlignment(SwingConstants.TOP); fontLabel.setVerticalAlignment(SwingConstants.TOP);
frFontPane = new FRFontPane(); frFontPane = new FRFontPane() {
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()); protected JPanel createRightPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p};
int[][] rowCount = {{1, 1}};
Component[][] components = new Component[][]{
new Component[]{fontSizeComboBox},
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
};
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()) {
@Override
public boolean shouldResponseNameListener() {
return true;
}
};
displayPositionGroup.setGlobalName(Inter.getLocText("FR-Designer_Tab_Style_Template"));
textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray()); textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray());
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor},
@ -84,7 +106,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void populateBean(WCardTagLayout ob) { public void populateBean(WCardTagLayout ob) {
//标题背景和字体属性设置在WCardLayout上做兼容 //标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout(); XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType());
textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType());
@ -100,14 +122,29 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public WCardTagLayout updateBean() { public WCardTagLayout updateBean() {
//标题背景和字体属性设置在WCardLayout上做兼容 //标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout(); XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart();
LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle();
FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont();
layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue());
layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont)); layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont));
WCardTagLayout layout = (WCardTagLayout) creator.toData(); WCardTagLayout layout = (WCardTagLayout) creator.toData();
boolean isHori = displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.TOP_POSITION.getType() || displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.BOTTOM_POSITION.getType();
if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Tab_Style_Template"))) {
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));
textDirectionGroup.setSelectedIndex(isHori ? WTabTextDirection.TEXT_HORI_DERECTION.getType() : WTabTextDirection.TEXT_VER_DIRECTION.getType());
layout.setHgap(isHori ? WCardTagLayout.DESIGNER_DEFAULT_GAP : 0);
layout.setVgap(isHori ? 0 : WCardTagLayout.DESIGNER_DEFAULT_GAP);
}
layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex())); layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex()));
layout.setTemplateStyle((TemplateStyle) templateStyleEditor.getValue()); TemplateStyle templateStyle = (TemplateStyle) templateStyleEditor.getValue();
if (!ComparatorUtils.equals(layout.getTemplateStyle(), templateStyle)) {
backgroundEditor.setValue(templateStyle.getDefaultBackground());
layoutBorderStyle.getTitle().setBackground(templateStyle.getDefaultBackground());
//重置内部tab的默认背景
xCardLayout.resetTabBackground(templateStyle);
layout.setTemplateStyle(templateStyle);
} else {
layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue());
}
return layout; return layout;
} }

5
designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java

@ -19,6 +19,7 @@ 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.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -77,12 +78,12 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify<WTabFitLayout> {
@Override @Override
public void populateBean(WTabFitLayout ob) { public void populateBean(WTabFitLayout ob) {
borderStyle.populate(ob);
paddingBoundPane.populate(ob); paddingBoundPane.populate(ob);
componentInterval.setValue(ob.getCompInterval()); componentInterval.setValue(ob.getCompInterval());
if(ob.getCurrentCard() == null){ if(ob.getCurrentCard() == null){
ob.setCurrentCard(getRelateSwitchButton(ob)); ob.setCurrentCard(getRelateSwitchButton(ob));
} }
borderStyle.populate(ob);
titleField.setText(ob.getCurrentCard().getText()); titleField.setText(ob.getCurrentCard().getText());
} }
@ -118,7 +119,9 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify<WTabFitLayout> {
public WTabFitLayout updateBean() { public WTabFitLayout updateBean() {
WTabFitLayout layout = (WTabFitLayout) creator.toData(); WTabFitLayout layout = (WTabFitLayout) creator.toData();
borderStyle.update(layout); borderStyle.update(layout);
if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) {
paddingBoundPane.update(layout); paddingBoundPane.update(layout);
}
int gap = (int)componentInterval.getValue(); int gap = (int)componentInterval.getValue();
setLayoutGap(gap, layout, (XWTabFitLayout)creator); setLayoutGap(gap, layout, (XWTabFitLayout)creator);
layout.getCurrentCard().setText(titleField.getText()); layout.getCurrentCard().setText(titleField.getText());

BIN
designer-realize/src/com/fr/design/images/splash_10.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

21
designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

@ -11,6 +11,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
@ -248,10 +249,17 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
} }
while (dialog.getParent() != null) { while (dialog.getParent() != null) {
dialog = dialog.getParent(); dialog = dialog.getParent();
if (dialog instanceof SmartInsertSubmitJobListPane) { if (dialog instanceof Dialog) {
((SmartInsertSubmitJobListPane)dialog).showParentDialog(); //这边需要另起一个线程设置可见,防止阻塞
} else if (dialog instanceof Dialog) { final Container finalDialog = dialog;
dialog.setVisible(true); SwingWorker worker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
finalDialog.setVisible(true);
return null;
}
};
worker.execute();
} }
} }
} }
@ -263,15 +271,14 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
} }
while (dialog.getParent() != null) { while (dialog.getParent() != null) {
dialog = dialog.getParent(); dialog = dialog.getParent();
if (dialog instanceof SmartInsertSubmitJobListPane) { if (dialog instanceof Dialog) {
((SmartInsertSubmitJobListPane)dialog).hideParentDialog();
} else if (dialog instanceof Dialog) {
// 条件属性中添加的控件的话有两层dialog,需要都隐藏 // 条件属性中添加的控件的话有两层dialog,需要都隐藏
dialog.setVisible(false); dialog.setVisible(false);
} }
} }
} }
/** /**
* 检测是否合法 * 检测是否合法
* @throws Exception * @throws Exception

31
designer-realize/src/com/fr/start/Designer.java

@ -43,19 +43,21 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.module.Module; import com.fr.module.Module;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.stable.BuildContext;
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.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.start.fx.SplashFx;
import com.fr.start.jni.SplashMac;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
import com.fr.start.server.FineEmbedServer;
import com.fr.start.server.ServerTray;
import javax.swing.JComponent; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.Component; import java.awt.*;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
@ -86,14 +88,29 @@ public class Designer extends BaseDesigner {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
SplashContext.getInstance().registerSplash(createSplash());
SplashContext.getInstance().show();
Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml");
//传递启动参数 //传递启动参数
designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args));
designerRoot.start(); designerRoot.start();
if (FRContext.getCurrentEnv() instanceof LocalEnv) { if (FRContext.getCurrentEnv() instanceof LocalEnv) {
// 预启动一下 // 预启动一下
StartServer.start(); FineEmbedServer.getInstance().start();
ServerTray.init();
} }
}
private static SplashStrategy createSplash() {
// 这里可以开接口加载自定义启动画面
if (OperatingSystem.isWindows()) {
return new SplashFx();
} else if (OperatingSystem.isMacOS()) {
return new SplashMac();
}
return new SplashFx();
} }
public Designer(String[] args) { public Designer(String[] args) {

142
designer-realize/src/com/fr/start/SplashContext.java

@ -0,0 +1,142 @@
package com.fr.start;
import com.fr.base.FRContext;
import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import com.fr.stable.module.ModuleAdapter;
import com.fr.stable.module.ModuleListener;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 启动动画策略
*
* @author vito
* @date 2018/6/5
*/
public class SplashContext {
private static final SplashContext SPLASH_CONTEXT = new SplashContext();
private SplashStrategy splashStrategy;
private String moduleID = "";
private int loadingIndex = 0;
private String[] loading = new String[]{"..", "....", "......"};
private static final String GUEST = getRandomUser();
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private ModuleListener listener;
public static SplashContext getInstance() {
return SPLASH_CONTEXT;
}
private SplashContext() {
}
/**
* 注册具体的启动动画
*/
public void registerSplash(SplashStrategy splashStrategy) {
this.splashStrategy = splashStrategy;
}
/**
* 注册监听
*/
public ModuleListener getModuleListener() {
initListener();
return listener;
}
/**
* 展示启动动画
*/
public void show() {
splashStrategy.show();
}
/**
* 隐藏启动动画
*/
public void hide() {
splashStrategy.hide();
// 窗口关闭后取消定时获取模块信息的timer
scheduler.shutdown();
// 一次性
splashStrategy = null;
}
private void initListener() {
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
}
}, 0, 300, TimeUnit.MILLISECONDS);
listener = new ModuleAdapter() {
@Override
public void onStartBefore(String moduleName, String moduleI18nName) {
moduleID = moduleI18nName;
loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
}
};
showThanks();
}
private void updateModuleLog(String text) {
splashStrategy.updateModuleLog(text);
}
private void updateThanksLog(String text) {
splashStrategy.updateThanksLog(text);
}
/**
* 获取随机感谢人员
*/
private static String getRandomUser() {
String[] allGuest = BBSConstants.getAllGuest();
if (allGuest.length == 0) {
return StringUtils.EMPTY;
}
int num = new Random().nextInt(allGuest.length);
return StringUtils.BLANK + allGuest[num];
}
/**
* 展示感谢信息
*/
private void showThanks() {
if (shouldShowThanks()) {
updateThanksLog(Inter.getLocText("FR-Designer_Thanks-To") + GUEST);
}
}
/**
* 是否显示鸣谢面板
*/
private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.CHINA, Locale.TAIWAN};
for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) {
return true;
}
}
return false;
}
}

210
designer-realize/src/com/fr/start/fx/FastGifImage.java

@ -0,0 +1,210 @@
package com.fr.start.fx;
import com.sun.imageio.plugins.gif.GIFImageReader;
import com.sun.imageio.plugins.gif.GIFImageReaderSpi;
import com.sun.javafx.tk.ImageLoader;
import com.sun.javafx.tk.PlatformImage;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.image.WritableImage;
import javafx.util.Duration;
import javax.imageio.stream.FileImageInputStream;
import java.io.File;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.regex.Pattern;
/**
* 边加载边播放的gif加载器
*
* @author daniel
*/
public class FastGifImage extends WritableImage {
private String url;
private int gifCount;
public FastGifImage(String url, int w, int h) {
super(w, h);
this.url = validateUrl(url);
seekCount();
initialize();
}
/**
* 给出gif帧数加快加载速度
*
* @param url gif url
* @param gifCount gif帧数
* @param w
* @param h
*/
public FastGifImage(String url, int gifCount, int w, int h) {
super(w, h);
this.url = validateUrl(url);
this.gifCount = gifCount;
initialize();
}
private void seekCount() {
try {
GIFImageReaderSpi spi = new GIFImageReaderSpi();
GIFImageReader gifReader = (GIFImageReader) spi.createReaderInstance();
gifReader.setInput(new FileImageInputStream(new File(new URI(url))));
gifCount = gifReader.getNumImages(true);
} catch (Exception e) {
e.printStackTrace();
}
}
private static final Pattern URL_QUICKMATCH = Pattern.compile("^\\p{Alpha}[\\p{Alnum}+.-]*:.*$");
private static String validateUrl(final String url) {
if (url == null) {
throw new NullPointerException("URL must not be null");
}
if (url.trim().isEmpty()) {
throw new IllegalArgumentException("URL must not be empty");
}
try {
if (!URL_QUICKMATCH.matcher(url).matches()) {
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
URL resource;
if (url.charAt(0) == '/') {
resource = contextClassLoader.getResource(url.substring(1));
} else {
resource = contextClassLoader.getResource(url);
}
if (resource == null) {
throw new IllegalArgumentException("Invalid URL or resource not found");
}
return resource.toString();
}
// Use URL constructor for validation
return new URL(url).toString();
} catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid URL" + e.getMessage());
} catch (final MalformedURLException e) {
throw new IllegalArgumentException("Invalid URL" + e.getMessage());
}
}
private void finishImage(Exception e) {
e.printStackTrace();
}
private void finishImage(ImageLoader loader) {
final Exception loadingException = loader.getException();
if (loadingException != null) {
finishImage(loadingException);
return;
}
initializeAnimatedImage(loader);
}
// Generates the animation Timeline for multiframe images.
private void initializeAnimatedImage(ImageLoader loader) {
animation = new Animation(this, loader);
animation.start();
}
// Support for animated images.
private Animation animation;
private static final class Animation {
final WeakReference<FastGifImage> imageRef;
final Timeline timeline;
final ImageLoader loader;
public Animation(final FastGifImage image, final ImageLoader loader) {
this.loader = loader;
imageRef = new WeakReference<FastGifImage>(image);
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
final int frameCount = loader.getFrameCount();
int duration = 0;
for (int i = 0; i < frameCount; ++i) {
addKeyFrame(i, duration);
duration = duration + loader.getFrameDelay(i);
}
// Note: we need one extra frame in the timeline to define how long
// the last frame is shown, the wrap around is "instantaneous"
addKeyFrame(0, duration);
}
public void start() {
timeline.play();
}
public void stop() {
timeline.stop();
}
private void updateImage(final int frameIndex) {
final FastGifImage image = imageRef.get();
if (image != null) {
image.setPlatformImagePropertyImpl(
loader.getFrame(frameIndex));
} else {
timeline.stop();
}
}
private void addKeyFrame(final int index, final double duration) {
timeline.getKeyFrames().add(
new KeyFrame(Duration.millis(duration),
new EventHandler() {
@Override
public void handle(Event event) {
updateImage(index);
}
}
));
}
}
private static Method method;
static {
try {
method = FastGifImage.class.getSuperclass().getSuperclass().getDeclaredMethod("platformImagePropertyImpl");
method.setAccessible(true);
} catch (Exception e) {
}
}
private void setPlatformImagePropertyImpl(PlatformImage image) {
try {
Object o = method.invoke(this);
Method method = o.getClass().getDeclaredMethod("set", Object.class);
method.setAccessible(true);
method.invoke(o, image);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
private void initialize() {
finishImage(new PrismImageLoader2(url, gifCount, (int) getRequestedWidth(), (int) getRequestedHeight(), isPreserveRatio(), isSmooth()));
}
}

211
designer-realize/src/com/fr/start/fx/PrismImageLoader2.java

@ -0,0 +1,211 @@
package com.fr.start.fx;
import com.sun.javafx.iio.ImageFrame;
import com.sun.javafx.iio.ImageLoadListener;
import com.sun.javafx.iio.ImageLoader;
import com.sun.javafx.iio.ImageMetadata;
import com.sun.javafx.iio.ImageStorageException;
import com.sun.javafx.iio.common.ImageTools;
import com.sun.javafx.iio.gif.GIFImageLoaderFactory;
import com.sun.javafx.tk.PlatformImage;
import com.sun.prism.Image;
import com.sun.prism.impl.PrismSettings;
import sun.util.logging.PlatformLogger;
import java.io.IOException;
import java.io.InputStream;
/**
* 边加载边播放的gif加载器
*
* @author daniel
*/
class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader {
private static PlatformLogger imageioLogger = null;
private Image[] images;
private int[] delayTimes;
private int width;
private int height;
private int gifCount = 1;
private Exception exception;
public PrismImageLoader2(final String url, int gifCount, final int width, final int height,
final boolean preserveRatio, final boolean smooth) {
this.gifCount = gifCount;
images = new Image[gifCount];
delayTimes = new int[gifCount];
this.width = width;
this.height = height;
new Thread() {
@Override
public void run() {
InputStream inputStream = null;
try {
inputStream = ImageTools.createInputStream(url);
loadAll(inputStream, width, height, preserveRatio, smooth);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public int getFrameCount() {
return gifCount;
}
@Override
public PlatformImage getFrame(int index) {
while (images[index] == null) {
synchronized (this) {
if (images[index] == null) {
try {
this.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
return images[index];
}
@Override
public int getFrameDelay(int index) {
// while (images[0] == null) {
// synchronized (this) {
// if(images[0] == null) {
// try {
// this.wait();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
// return 0;
// }
// return delayTimes[0];
// 直接使用第一帧的时间
return 40;
}
@Override
public int getLoopCount() {
return 0;
}
@Override
public Exception getException() {
return exception;
}
private void loadAll(InputStream stream, int w, int h,
boolean preserveRatio, boolean smooth) {
ImageLoadListener listener = new PrismLoadListener();
try {
ImageLoader loader = null;
loader = GIFImageLoaderFactory.getInstance().createImageLoader(stream);
loader.addListener(listener);
for (int i = 0; i < gifCount; i++) {
ImageFrame imageFrame = loader.load(i, w, h, preserveRatio, smooth);
images[i] = convert(imageFrame);
synchronized (this) {
this.notify();
}
}
} catch (ImageStorageException e) {
handleException(e);
} catch (Exception e) {
handleException(e);
}
}
private void handleException(final ImageStorageException isException) {
// unwrap ImageStorageException if possible
final Throwable exceptionCause = isException.getCause();
if (exceptionCause instanceof Exception) {
handleException((Exception) exceptionCause);
} else {
handleException((Exception) isException);
}
}
private void handleException(final Exception exception) {
if (PrismSettings.verbose) {
exception.printStackTrace(System.err);
}
this.exception = exception;
}
private Image convert(ImageFrame imgFrames) {
ImageFrame frame = imgFrames;
Image image = Image.convertImageFrame(frame);
ImageMetadata metadata = frame.getMetadata();
if (metadata != null) {
Integer delay = metadata.delayTime;
if (delay != null) {
delayTimes[0] = delay.intValue();
}
}
return image;
}
/**
* Returns the PlatformLogger for logging imageio-related activities.
*/
private static synchronized PlatformLogger getImageioLogger() {
if (imageioLogger == null) {
imageioLogger = PlatformLogger.getLogger("imageio");
}
return imageioLogger;
}
private class PrismLoadListener implements ImageLoadListener {
@Override
public void imageLoadWarning(ImageLoader loader, String message) {
getImageioLogger().warning(message);
}
@Override
public void imageLoadProgress(ImageLoader loader,
float percentageComplete) {
// progress only matters when backgroundLoading=true, but
// currently we are relying on AbstractRemoteResource for tracking
// progress of the InputStream, so there's no need to implement
// this for now; eventually though we might want to consider
// moving away from AbstractRemoteResource and instead use
// the built-in support for progress in the javafx-iio library...
}
@Override
public void imageLoadMetaData(ImageLoader loader, ImageMetadata metadata) {
// We currently have no need to listen for ImageMetadata ready.
}
}
}

60
designer-realize/src/com/fr/start/fx/SplashFx.java

@ -0,0 +1,60 @@
package com.fr.start.fx;
import com.fr.start.SplashStrategy;
import javafx.application.Application;
import javafx.application.Platform;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* JavaFx方式启动启动动画这种方式在mac下与
* swing一起启动会会出现线程死锁jvm等问题
* 所以这个方式仅用于windows上
*
* @author vito
* @date 2018/6/4
* @see com.fr.start.jni.SplashMac
*/
public class SplashFx implements SplashStrategy {
private SplashFxWindow test;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor();
@Override
public void show() {
SERVICE.execute(new Runnable() {
@Override
public void run() {
Application.launch(SplashFxWindow.class);
}
});
test = SplashFxWindow.waitForStartUpTest();
}
@Override
public void hide() {
Platform.exit();
}
@Override
public void updateModuleLog(final String text) {
Platform.runLater(new Runnable() {
@Override
public void run() {
test.updateModuleInfo(text);
}
});
}
@Override
public void updateThanksLog(final String text) {
Platform.runLater(new Runnable() {
@Override
public void run() {
test.updateThanks(text);
}
});
}
}

134
designer-realize/src/com/fr/start/fx/SplashFxWindow.java

@ -0,0 +1,134 @@
package com.fr.start.fx;
import com.bulenkov.iconloader.util.JBUI;
import com.fr.base.FRContext;
import com.fr.stable.OperatingSystem;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.util.concurrent.CountDownLatch;
/**
* JavaFx启动动画窗口
*
* @author vito
*/
public class SplashFxWindow extends Application {
private static float JBUI_INIT_SCALE = JBUI.scale(1f);
private static final String ARIAL_FONT_NAME = "Arial";
private static final String PF_FONT_NAME = "PingFang";
private static final String YAHEI_FONT_NAME = "Microsoft YaHei";
private static final int MODULE_INFO_LEFT_MARGIN = 36;
private static final int MODULE_INFO_BOTTOM_MARGIN = 28;
private static final int THINKS_BOTTOM_RIGHT = 35;
private static final int THINKS_BOTTOM_MARGIN = 27;
private static final int WINDOW_WIDTH = 640;
private static final int WINDOW_HEIGHT = 360;
private static final int FONT = 12;
private static final int FRAME_COUNT = 254;
private static final String THINKS_COLOR = "#82b1ce";
private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
private static final CountDownLatch LATCH = new CountDownLatch(1);
private static SplashFxWindow app = null;
private Text moduleInfo;
private Text thanks;
private static int uiScale(int i) {
return (int) (i * JBUI_INIT_SCALE);
}
/**
* 获取当前运行实例黑科技
*
* @return 运行实例
*/
public static SplashFxWindow waitForStartUpTest() {
try {
LATCH.await();
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return app;
}
private static void setApp(SplashFxWindow window) {
app = window;
LATCH.countDown();
}
public SplashFxWindow() {
setApp(this);
}
@Override
public void start(Stage primaryStage) {
AnchorPane root = new AnchorPane();
primaryStage.initStyle(StageStyle.TRANSPARENT);
Image image = new FastGifImage(SPLASH_PATH, FRAME_COUNT, WINDOW_WIDTH, WINDOW_HEIGHT);
ImageView gif = new ImageView(image);
AnchorPane.setBottomAnchor(gif, 0d);
AnchorPane.setTopAnchor(gif, 0d);
AnchorPane.setLeftAnchor(gif, 0d);
AnchorPane.setRightAnchor(gif, 0d);
Font font;
if (OperatingSystem.isWindows()) {
font = new Font(YAHEI_FONT_NAME, uiScale(FONT));
} else if (OperatingSystem.isMacOS()) {
font = new Font(PF_FONT_NAME, uiScale(FONT));
} else {
font = new Font(ARIAL_FONT_NAME, uiScale(FONT));
}
moduleInfo = new Text();
moduleInfo.setFont(font);
moduleInfo.setFill(Color.WHITE);
AnchorPane.setLeftAnchor(moduleInfo, (double) uiScale(MODULE_INFO_LEFT_MARGIN));
AnchorPane.setBottomAnchor(moduleInfo, (double) uiScale(MODULE_INFO_BOTTOM_MARGIN));
thanks = new Text();
thanks.setFont(font);
thanks.setFill(Color.valueOf(THINKS_COLOR));
AnchorPane.setRightAnchor(thanks, (double) uiScale(THINKS_BOTTOM_RIGHT));
AnchorPane.setBottomAnchor(thanks, (double) uiScale(THINKS_BOTTOM_MARGIN));
root.getChildren().add(gif);
root.getChildren().add(moduleInfo);
root.getChildren().add(thanks);
Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT, null);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* 更新模块信息
*
* @param s 文字
*/
public void updateModuleInfo(String s) {
moduleInfo.setText(s);
}
/**
* 更新欢迎信息
*
* @param s 文字
*/
public void updateThanks(String s) {
thanks.setText(s);
}
}

69
designer-realize/src/com/fr/start/jni/SplashJNI.java

@ -0,0 +1,69 @@
package com.fr.start.jni;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
/**
* Splash JNI调用jni类改名或者移包之后
* 必须重新编译动态库
*
* @author vito
* @date 2018/6/4
*/
public class SplashJNI {
static {
try {
System.setProperty("java.library.path", ".");
System.loadLibrary("splash");
} catch (UnsatisfiedLinkError e) {
loadLibraryFromJar("/com/fr/start/jni/splash.dylib");
}
}
/**
* 显示启动动画窗口
*/
public native void show(String path);
/**
* 隐藏启动动画窗口
*/
public native void hide();
/**
* 设置模块加载信息
*/
public native void updateModuleLog(String text);
/**
* 设置感谢文字
*/
public native void updateThanksLog(String text);
/**
* 从jar中加载动态库
*
* @param path 路径/com/a/b
* @throws UnsatisfiedLinkError 没有找到合适的动态库
*/
private static void loadLibraryFromJar(String path) throws UnsatisfiedLinkError {
try (InputStream inputStream = SplashJNI.class.getResourceAsStream(path)) {
File tempLib = File.createTempFile(path, "");
byte[] buffer = new byte[1024];
int read = -1;
try (FileOutputStream fileOutputStream = new FileOutputStream(tempLib)) {
while ((read = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, read);
}
}
System.load(tempLib.getAbsolutePath());
} catch (Exception e) {
throw new UnsatisfiedLinkError("Unable to open " + path + " from jar file.");
}
}
}

95
designer-realize/src/com/fr/start/jni/SplashMac.java

@ -0,0 +1,95 @@
package com.fr.start.jni;
import com.fr.base.FRContext;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.start.SplashContext;
import com.fr.start.SplashStrategy;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* mac上使用jni方式绘制gif不使用javafx有两个原因
* 1.mac上javafx和swing同时启动会导致卡死
* 2.platform.exit会导致设计器崩溃
*
* @author vito
* @see com.fr.start.fx.SplashFx
*/
public class SplashMac implements SplashStrategy {
private static final String SPLASH_CACHE_NAME = "splash_10.gif";
private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
private SplashJNI jni;
public SplashMac() {
jni = new SplashJNI();
}
/**
* 将jar中的资源拷贝到缓存文件夹
*
* @return 路径
*/
private static String loadResFromJar() {
File tempLib = null;
try (InputStream inputStream = SplashContext.class.getResourceAsStream(SplashMac.SPLASH_PATH)) {
if (inputStream == null) {
FRContext.getLogger().error("Unable to copy " + SplashMac.SPLASH_PATH + " from jar file.");
return StringUtils.EMPTY;
}
tempLib = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), SPLASH_CACHE_NAME));
byte[] buffer = new byte[1024];
int read = -1;
try (FileOutputStream fileOutputStream = new FileOutputStream(tempLib)) {
while ((read = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, read);
}
}
return tempLib.getAbsolutePath();
} catch (IOException e) {
if (tempLib != null) {
tempLib.deleteOnExit();
}
// 直接抛异常
throw new RuntimeException("Unable to copy " + SplashMac.SPLASH_PATH + " from jar file.");
}
}
@Override
public void show() {
if (jni != null) {
File splash = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), SPLASH_CACHE_NAME));
String path = splash.exists() ? splash.getAbsolutePath() : loadResFromJar();
jni.show(path);
}
}
@Override
public void hide() {
if (jni != null) {
jni.hide();
jni = null;
}
}
@Override
public void updateModuleLog(String text) {
if (jni != null) {
jni.updateModuleLog(text);
}
}
@Override
public void updateThanksLog(String text) {
if (jni != null) {
jni.updateThanksLog(text);
}
}
}

BIN
designer-realize/src/com/fr/start/jni/splash.dylib

Binary file not shown.

4
designer-realize/src/com/fr/start/module/DesignerEnvProvider.java

@ -19,7 +19,7 @@ import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.start.EnvSwitcher; import com.fr.start.EnvSwitcher;
import com.fr.start.StartServer; import com.fr.start.ServerStarter;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -38,7 +38,7 @@ public class DesignerEnvProvider extends Activator {
for (String arg : args) { for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) { if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
StartServer.browserDemoURL(); ServerStarter.browserDemoURL();
break; break;
} }
} }

22
designer-realize/src/com/fr/start/module/DesignerStartup.java

@ -5,9 +5,7 @@ import com.fr.stable.CoreActivator;
import com.fr.stable.module.ModuleListener; import com.fr.stable.module.ModuleListener;
import com.fr.start.Designer; import com.fr.start.Designer;
import com.fr.start.EnvSwitcher; import com.fr.start.EnvSwitcher;
import com.fr.start.ReportSplashPane; import com.fr.start.SplashContext;
import com.fr.start.SplashWindow;
import com.fr.startup.EnvInitializer;
import com.fr.startup.activators.BasicActivator; import com.fr.startup.activators.BasicActivator;
/** /**
@ -20,8 +18,8 @@ public class DesignerStartup extends Activator {
startSub(PreStartActivator.class); startSub(PreStartActivator.class);
//启动基础部分 //启动基础部分
startSub(BasicActivator.class); startSub(BasicActivator.class);
//启动画面 //启动画面注册监听,必须在初始化国际化之后注册监听
SplashWindow splashWindow = createSplashWindow(); registerSplashListener();
String[] args = getModule().upFindSingleton(StartupArgs.class).get(); String[] args = getModule().upFindSingleton(StartupArgs.class).get();
Designer designer = new Designer(args); Designer designer = new Designer(args);
//启动env //启动env
@ -33,17 +31,15 @@ public class DesignerStartup extends Activator {
//启动设计器界面 //启动设计器界面
designer.show(args); designer.show(args);
//启动画面结束 //启动画面结束
splashWindow.setVisible(false); SplashContext.getInstance().hide();
splashWindow.dispose();
startSub(StartFinishActivator.class); startSub(StartFinishActivator.class);
} }
private SplashWindow createSplashWindow() { /**
* 注册启动动画监听器
ReportSplashPane reportSplashPane = new ReportSplashPane(); */
SplashWindow splashWindow = new SplashWindow(reportSplashPane); private void registerSplashListener() {
getModule().setSingleton(ModuleListener.class, reportSplashPane.getModuleListener()); getModule().setSingleton(ModuleListener.class, SplashContext.getInstance().getModuleListener());
return splashWindow;
} }
@Override @Override

1
designer-realize/src/com/fr/start/module/PreStartActivator.java

@ -25,7 +25,6 @@ public class PreStartActivator extends Activator {
public void start() { public void start() {
RestartHelper.deleteRecordFilesWhenStart(); RestartHelper.deleteRecordFilesWhenStart();
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
SiteCenter.getInstance(); SiteCenter.getInstance();
if (checkMultiStart()) { if (checkMultiStart()) {
return; return;

Loading…
Cancel
Save