Browse Source

Merge pull request #80 in DESIGN/design from ~KERRY/design_10.0:feature/10.0 to feature/10.0

* commit '3d9b545131a5561eb5f92e3525f71c5c591761c8':
  REPORT-8354 9.0之前开发的功能与bug patch到10.0
master
superman 7 years ago
parent
commit
55a2b37ca9
  1. 20
      designer-base/src/com/fr/design/gui/ispinner/UISpinner.java
  2. 4
      designer-base/src/com/fr/design/gui/style/FRFontPane.java
  3. 37
      designer-base/src/com/fr/design/icon/IconPathConstants.java
  4. BIN
      designer-base/src/com/fr/design/images/control/newEdit.png
  5. 15
      designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java
  6. 14
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java
  7. 18
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java
  8. 40
      designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java
  9. 14
      designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  10. 5
      designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java
  11. 95
      designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java
  12. 70
      designer-base/src/com/fr/design/style/background/BackgroundFactory.java
  13. 88
      designer-base/src/com/fr/design/style/background/BackgroundTabPane.java
  14. 28
      designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java
  15. 28
      designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java
  16. 3
      designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java
  17. 16
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  18. 62
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java
  19. 9
      designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  20. 3
      designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java
  21. 3
      designer-form/src/com/fr/design/designer/beans/models/StateModel.java
  22. 14
      designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java
  23. 33
      designer-form/src/com/fr/design/designer/creator/XButton.java
  24. 35
      designer-form/src/com/fr/design/designer/creator/XChartEditor.java
  25. 44
      designer-form/src/com/fr/design/designer/creator/XCreator.java
  26. 10
      designer-form/src/com/fr/design/designer/creator/XCreatorTools.java
  27. 16
      designer-form/src/com/fr/design/designer/creator/XElementCase.java
  28. 4
      designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java
  29. 15
      designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  30. 53
      designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  31. 14
      designer-form/src/com/fr/design/designer/creator/XWTitleLayout.java
  32. 7
      designer-form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java
  33. 27
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  34. 212
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  35. 52
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  36. 173
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  37. 108
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  38. 49
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  39. 147
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  40. 21
      designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  41. 25
      designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  42. 6
      designer-form/src/com/fr/design/form/util/XCreatorConstants.java
  43. 13
      designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java
  44. 5
      designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java
  45. 30
      designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java
  46. 14
      designer-form/src/com/fr/design/mainframe/ComponentTree.java
  47. 48
      designer-form/src/com/fr/design/mainframe/CoverPane.java
  48. 6
      designer-form/src/com/fr/design/mainframe/CoverReportPane.java
  49. 2
      designer-form/src/com/fr/design/mainframe/FormArea.java
  50. 4
      designer-form/src/com/fr/design/mainframe/FormDesignerUI.java
  51. 3
      designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java
  52. 45
      designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java
  53. 3
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  54. 1
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  55. 17
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java
  56. 34
      designer-form/src/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  57. 12
      designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java
  58. 55
      designer-form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  59. 5
      designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java
  60. 21
      designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

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

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

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

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

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

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

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

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

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

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

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

@ -11,15 +11,17 @@ 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.
*/ */
public abstract class BackgroundCompPane<T extends Widget> extends BasicPane { public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
protected UIButtonGroup backgroundHead; protected UIButtonGroup backgroundHead;
protected AccessibleImgBackgroundEditor initialBackgroundEditor; protected AccessibleImgBackgroundEditor initalBackgroundEditor;
protected AccessibleImgBackgroundEditor overBackgroundEditor; protected AccessibleImgBackgroundEditor overBackgroundEditor;
protected AccessibleImgBackgroundEditor clickBackgroundEditor; protected AccessibleImgBackgroundEditor clickBackgroundEditor;
private JPanel panel; private JPanel panel;
@ -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;
@ -42,11 +42,11 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
double[] columnSize = {p, f}; double[] columnSize = {p, f};
int[][] rowCount = {{1, 1},{1, 1},{1, 1}}; int[][] rowCount = {{1, 1},{1, 1},{1, 1}};
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")), initalBackgroundEditor},
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(){
initalBackgroundEditor = 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) {
} }
}); });

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

@ -48,11 +48,8 @@ public class FormDeleteAction extends FormWidgetEditAction {
if (designer == null) { if (designer == null) {
return false; return false;
} }
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
designer.getSelectionModel().deleteSelection(); designer.getSelectionModel().deleteSelection();
creator.deleteRelatedComponent(creator, designer);
return false; return false;
} }
} }

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

33
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,6 +22,19 @@ 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
@ -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属性改变触发其他操作
* *

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

@ -4,6 +4,7 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
@ -21,6 +22,7 @@ import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -32,6 +34,7 @@ import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
@ -72,12 +75,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
add(editor, BorderLayout.CENTER); add(editor, BorderLayout.CENTER);
} }
if (initSize.width == 0) { setInitSize(initSize);
initSize.width = this.initEditorSize().width;
}
if (initSize.height == 0) {
initSize.height = this.initEditorSize().height;
}
this.setPreferredSize(initSize); this.setPreferredSize(initSize);
this.setSize(initSize); this.setSize(initSize);
this.setMaximumSize(initSize); this.setMaximumSize(initSize);
@ -101,6 +99,18 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
} }
/**
* 初始化组件大小
*/
public void setInitSize(Dimension initSize) {
if (initSize.width == 0) {
initSize.width = this.initEditorSize().width;
}
if (initSize.height == 0) {
initSize.height = this.initEditorSize().height;
}
}
/** /**
* 备份当前大小 * 备份当前大小
*/ */
@ -282,6 +292,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
*@param formEditor 设计界面组件 *@param formEditor 设计界面组件
*@return 工具界面 *@return 工具界面
*/ */
@Override
public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) { public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) {
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
if (isDedicateContainer()) { if (isDedicateContainer()) {
@ -381,10 +392,20 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 控件树不显示此组件 * 控件树不显示此组件
* @param path 控件树list * @param path 控件树list
*/ */
public void notShowInComponentTree(ArrayList<Component> path) { @Override
public void notShowInComponentTree(List<Component> path) {
return; return;
} }
/**
* 获取其在控件树上可见父层
* @return 组件
*/
@Override
public Component getParentShow(){
return this.getParent();
}
/** /**
* 重置组件的名称 * 重置组件的名称
* @param name 名称 * @param name 名称
@ -678,6 +699,15 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
// do nothing // do nothing
} }
/**
* 编辑状态的时候需要重新绘制下边框
*
*/
public void paintBorder(Graphics g, Rectangle bounds){
GraphHelper.draw(g, bounds, Constants.LINE_MEDIUM);
}
/** /**
* 创建右击弹出菜单 * 创建右击弹出菜单
* *

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

@ -4,7 +4,7 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Component; import java.awt.Component;
import java.util.ArrayList; import java.util.List;
/** /**
* @author jim * @author jim
@ -17,7 +17,7 @@ public interface XCreatorTools {
* 控件树不显示此组件 * 控件树不显示此组件
* @param path 控件树list * @param path 控件树list
*/ */
void notShowInComponentTree(ArrayList<Component> path); void notShowInComponentTree(List<Component> path);
/** /**
* 重置组件的名称 * 重置组件的名称
@ -55,4 +55,10 @@ public interface XCreatorTools {
*/ */
boolean isDedicateContainer(); boolean isDedicateContainer();
/**
* 获取其在控件树上可见父层
* @return 组件
*/
Component getParentShow();
} }

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

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

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

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

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

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

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

@ -3,6 +3,9 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.GraphHelper;
import com.fr.base.iofileattr.SharableAttrMark;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
@ -11,10 +14,12 @@ import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.Connector; import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
@ -23,7 +28,10 @@ import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen; import com.fr.general.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.share.ShareConstants;
import com.fr.stable.Constants;
import javax.swing.Icon;
import java.awt.*; import java.awt.*;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -42,6 +50,10 @@ public class XWAbsoluteLayout extends XLayoutContainer {
private static final int EDIT_BTN_HEIGHT = 24; private static final int EDIT_BTN_HEIGHT = 24;
private int minWidth = WLayout.MIN_WIDTH; private int minWidth = WLayout.MIN_WIDTH;
private int minHeight = WLayout.MIN_HEIGHT; private int minHeight = WLayout.MIN_HEIGHT;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249);
private static final int BORDER_WIDTH = 1;
private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0; protected double containerPercent = 1.0;
@ -437,15 +449,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
//画白色的编辑层 //画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(Color.WHITE); g2d.setColor(XCreatorConstants.COVER_COLOR);
g2d.fillRect(x, y, w, h); g2d.fillRect(x, y, w, h);
//画编辑按钮所在框 //画编辑按钮所在框
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f);
g2d.setColor(XCreatorConstants.EDIT_COLOR);
g2d.setComposite(alphaComposite);
g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4);
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标 //画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH);
g2d.drawImage( g2d.drawImage(
image, image,
(x + w / 2 - 23), (x + w / 2 - 23),
@ -455,9 +470,35 @@ public class XWAbsoluteLayout extends XLayoutContainer {
null, null,
this this
); );
g2d.setColor(Color.BLACK); g2d.setColor(Color.WHITE);
//画编辑文字 //画编辑文字
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5);
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM);
paintExtro(g);
}
}
public void paintExtro(Graphics g) {
if (this.toData().getWidgetAttrMark(SharableAttrMark.XML_TAG) != null) {
int width = getWidth() - ShareConstants.SHARE_EL_CONTROL_BUTTON_HW;
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillArc(width, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW,
0, 360);
controlMode.paintIcon(this, g, width, 0);
}
}
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if(editable){
g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 5, bounds.height + 5), Constants.LINE_LARGE);
g.setColor(INNER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height), Constants.LINE_MEDIUM);
}else if(!isMouseEnter){
super.paintBorder(g, bounds);
} }
} }

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;

27
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,9 +16,9 @@ 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;
@ -29,12 +28,10 @@ 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");
@ -86,6 +83,7 @@ public class XCardAddButton extends XButton{
* @param e 点击事件 * @param e 点击事件
* *
*/ */
@Override
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ 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);
@ -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;

212
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();
@ -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();
@ -282,19 +280,18 @@ 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改为选中状态
@ -306,11 +303,14 @@ public class XCardSwitchButton extends XButton {
} }
} }
@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);
@ -322,69 +322,41 @@ public class XCardSwitchButton extends XButton {
} }
//画背景 //画背景
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();
Background initialBackground = wTabFitLayout.getInitialBackground();
Background selectBackground = wTabFitLayout.getClickBackground();
if (button.isShowButton()) { if (button.isShowButton()) {
this.rebuid(); this.setContentBackground(selectBackground == null ? templateStyle.getSelectBackground() : selectBackground);
background = ColorBackground.getInstance(CHOOSED_GRAL);
this.setContentBackground(background);
} 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布局
@ -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);
}
}
}
} }

52
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 表单设计器
* *
*/ */
@Override
public void deleteRelatedComponent(XCreator creator, FormDesigner designer){ 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();
}
}
} }

173
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布局主体框架
@ -42,13 +60,13 @@ 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,6 +377,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* @param editingMouseListener 鼠标点击位置处理器 * @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件 * @param e 鼠标点击事件
*/ */
@Override
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
@ -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);
}
} }

108
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,17 +343,23 @@ 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()) {
@ -339,51 +375,36 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} 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";
} }

147
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,6 +256,7 @@ public class XWTabFitLayout extends XWFitLayout {
* @param designer 表单设计器 * @param designer 表单设计器
* *
*/ */
@Override
public void deleteRelatedComponent(XCreator creator, FormDesigner designer){ public void deleteRelatedComponent(XCreator creator, FormDesigner designer){
//逐层回溯找出相关的layout和对应的tab按钮 //逐层回溯找出相关的layout和对应的tab按钮
XWTabFitLayout fitLayout = (XWTabFitLayout)creator; XWTabFitLayout fitLayout = (XWTabFitLayout)creator;
@ -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);
@ -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;
} }

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

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

13
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,6 +94,9 @@ 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());

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

30
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;
@ -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,7 +151,7 @@ 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);
@ -157,13 +163,13 @@ public class LayoutBorderPreviewPane extends JPanel{
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

@ -222,21 +222,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();
@ -245,7 +237,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;

45
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(){
initalBackgroundEditor = 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) initalBackgroundEditor.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); initalBackgroundEditor.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()); initalBackgroundEditor.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);
} }

17
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();
int size = (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(ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){
parentBounds.height = (int)cardTagWidth.getValue(); 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;
} }
} }

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

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

Loading…
Cancel
Save