Browse Source

REPORT-8354 9.0之前开发的功能与bug patch到10.0

master
kerry 6 years ago
parent
commit
3d9b545131
  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. 74
      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. 35
      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. 39
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  34. 244
      designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  35. 70
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  36. 185
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  37. 126
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  38. 55
      designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  39. 195
      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. 8
      designer-form/src/com/fr/design/form/util/XCreatorConstants.java
  43. 33
      designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java
  44. 7
      designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java
  45. 38
      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. 19
      designer-form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java
  56. 36
      designer-form/src/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  57. 14
      designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java
  58. 59
      designer-form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  59. 7
      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.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.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.ButtonUI;
import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
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 {

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 UIComboBox fontNameComboBox;
private UIComboBox fontSizeStyleComboBox;
private UIComboBox fontSizeComboBox;
protected UIComboBox fontSizeComboBox;
private UIToggleButton bold;
private UIToggleButton italic;
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);
}
private JPanel createRightPane() {
protected JPanel createRightPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
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.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fun.JavaScriptActionProvider;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext;
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.general.Inter;
import com.fr.js.JavaScript;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
@ -105,7 +104,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
callPane.populateBean(getCall());
BasicDialog dialog = callPane.showWindow(DesignerContext.getDesignerFrame());
BasicDialog dialog = callPane.showWindow(SwingUtilities.getWindowAncestor(JavaScriptActionPane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override

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

@ -1,14 +1,15 @@
package com.fr.design.mainframe.widget.accessibles;
import java.awt.Dimension;
import javax.swing.SwingUtilities;
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.DialogActionAdapter;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.style.background.BackgroundButtonPane;
import com.fr.general.Background;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
private BackgroundButtonPane choosePane;
@ -18,7 +19,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
@Override
protected void showEditorPane() {
choosePane = new BackgroundButtonPane();
choosePane = initBackgroundPane();
choosePane.setPreferredSize(new Dimension(600, 400));
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@ -32,4 +33,9 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
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;
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.BookMarkTemplateStyle;
import com.fr.general.cardtag.CardTemplateStyle;
import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.MenuTemplateStyle;
import com.fr.general.cardtag.PentagonTemplateStyle;
import com.fr.general.cardtag.TrapezoidTemplateStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.general.cardtag.TrapezoidTemplateStyle;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
@ -41,11 +41,11 @@ public class TemplateStylePane extends BasicPane {
listModel = new DefaultListModel();
listModel.addElement(new DefaultTemplateStyle());
listModel.addElement(new CardTemplateStyle());
listModel.addElement(new BannerTemplateStyle());
listModel.addElement(new BookMarkTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new MenuTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new TrapezoidTemplateStyle());
listModel.addElement(new BannerTemplateStyle());
styleList = new JList(listModel);
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 {
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;
@ -32,6 +33,6 @@ public class TemplateStylePreviewPane extends JPanel {
super.paint(g);
Graphics2D g2d = (Graphics2D) g.create();
Image image = BaseUtils.readImage(templateStyle.getPreview());
g2d.drawImage(image, 0, 0, WIDTH, HEIGHT, null);
g2d.drawImage(image, 0, OFFSETY, WIDTH, HEIGHT, null);
}
}

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

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

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

@ -1,13 +1,29 @@
package com.fr.design.style.background;
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.fun.BackgroundUIProvider;
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.GeneralContext;
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.Map;
@ -29,9 +45,51 @@ public class BackgroundFactory {
registerBrowserImageBackground(browser);
registerExtra(map);
registerExtra(browser);
listenPlugin();
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) {
map.put(null, BackgroundUIWrapper.create()
.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) {
map.put(ImageFileBackground.class, BackgroundUIWrapper.create()
map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
}
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")));
}
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()
.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")));
}
@ -139,7 +197,7 @@ public class BackgroundFactory {
return new NullBackgroundPane();
}
private static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) {
public static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) {
Class<? extends BackgroundDetailPane> clazz = wrapper.getType();
if (clazz == null) {
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.general.Inter;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by ibm on 2017/8/6.
*/
public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
protected UIButtonGroup backgroundHead;
protected AccessibleImgBackgroundEditor initialBackgroundEditor;
protected AccessibleImgBackgroundEditor initalBackgroundEditor;
protected AccessibleImgBackgroundEditor overBackgroundEditor;
protected AccessibleImgBackgroundEditor clickBackgroundEditor;
private JPanel panel;
@ -31,9 +33,7 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel headLabel = createUILable();
initialBackgroundEditor = new AccessibleImgBackgroundEditor();
overBackgroundEditor = new AccessibleImgBackgroundEditor();
clickBackgroundEditor = new AccessibleImgBackgroundEditor();
initBackgroundEditor();
String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")};
double f = TableLayout.FILL;
@ -42,11 +42,11 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1},{1, 1},{1, 1}};
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-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));
backgroundHead = new UIButtonGroup(titles);
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(){
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.DocumentListener;
import javax.swing.plaf.basic.BasicComboBoxUI;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* Created by kerry on 2017/9/14.
@ -66,14 +67,29 @@ public class UIComboBoxNoArrow extends UIComboBox {
super();
this.comboBox = comboBox;
textField.getDocument().addDocumentListener(this);
textField.addFocusListener(new FocusListener() {
textField.addMouseListener(new MouseListener() {
@Override
public void focusGained(FocusEvent e) {
public void mouseClicked(MouseEvent e) {
changeHandler();
}
@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) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
designer.getSelectionModel().deleteSelection();
creator.deleteRelatedComponent(creator, designer);
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;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.general.ComparatorUtils;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
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.properties.FRBorderLayoutConstraints;
import com.fr.design.form.layout.FRBorderLayout;
import com.fr.form.ui.container.WBorderLayout;
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 {
@ -36,9 +35,6 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
* @param creator 组件
*/
public void fix(XCreator creator) {
if(creator.acceptType(XWCardTagLayout.class)){
creator = (XCreator) creator.getParent();
}
FRBorderLayout layout = (FRBorderLayout)container.getFRLayout();
Object constraints = layout.getConstraints(creator);
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) {

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) {
calculateNoRelatedWhileRightTop(rec, rightComp);
} 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);
}
private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) {
rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width);
private void calculateNoRelatedWhileRightBott(Rectangle bound) {
Component rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width);
if(rcomp == null){
return;
}
int ry = rcomp.getY();
int rh = rcomp.getHeight();
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() {
XCreator[] roots = selection.getSelectedCreators();
if (roots.length > 0) {
boolean isInPara = true; // 在参数面板内删除控件
for (XCreator creator : roots) {
@ -245,10 +244,12 @@ public class SelectionModel {
designer.removeParaComponent();
}
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
creator.deleteRelatedComponent(creator, designer);
creator.removeAll();
// 清除被选中的组件
selection.reset();
}
setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent());
// 触发事件
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
private void setDependLinePainter(MouseEvent e) {
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
if (comp == null) {
return;
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator();
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 java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.List;
/**
* 一些控件专属的容器如标题容器sclae容器
@ -27,6 +28,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* @return 属性名
* @throws IntrospectionException
*/
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[0];
}
@ -50,7 +52,8 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
*
* @param path 控件树list
*/
public void notShowInComponentTree(ArrayList<Component> path) {
@Override
public void notShowInComponentTree(List<Component> path) {
path.remove(path.size() - 1);
}
@ -59,6 +62,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
*
* @param name 名称
*/
@Override
public void resetCreatorName(String name) {
super.resetCreatorName(name);
XCreator child = getXCreator(XWScaleLayout.INDEX);
@ -70,6 +74,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
* 重置组件的可见性
* @param visible 可见性
*/
@Override
public void resetVisible(boolean visible){
super.resetVisible(visible);
XCreator child = getXCreator(XWScaleLayout.INDEX);
@ -80,6 +85,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
*
* @return 组件
*/
@Override
public XCreator getPropertyDescriptorCreator() {
return getXCreator(XWScaleLayout.INDEX);
}
@ -89,6 +95,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
*
* @return 是则返回true
*/
@Override
public boolean isComponentTreeLeaf() {
return true;
}
@ -98,6 +105,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
*
* @return 是则返回true
*/
@Override
public boolean isDedicateContainer() {
return true;
}

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

@ -3,20 +3,6 @@
*/
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.background.GradientBackground;
import com.fr.design.form.util.XCreatorConstants;
@ -36,13 +22,26 @@ import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.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
* @since 6.5.3
*/
public class XButton extends XWidgetCreator {
public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210),GradientBackground.TOP2BOTTOM);
public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210), GradientBackground.TOP2BOTTOM);
public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12);
public final static Color DEFAULTFOREGROUNDCOLOR = Color.BLACK;
private Background bg;
@ -198,10 +197,14 @@ public class XButton extends XWidgetCreator {
protected JComponent initEditor() {
if (editor == null) {
editor = new UILabel();
contentLabel = new UILabel();
contentLabel = initContentLabel();
}
return editor;
}
protected UILabel initContentLabel() {
return new UILabel();
}
@Override
public void paintComponent(Graphics g) {

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

@ -6,6 +6,7 @@ import java.beans.IntrospectionException;
import javax.swing.*;
import com.fr.base.GraphHelper;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.beans.AdapterBus;
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.design.form.util.XCreatorConstants;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
/**
@ -32,13 +34,18 @@ import com.fr.stable.core.PropertyChangeAdapter;
*/
public class XChartEditor extends XBorderStyleWidgetCreator {
private static final long serialVersionUID = -7009439442104836657L;
private static final int BORDER_WIDTH = 2;
//具体来说是DesignerEditor<SimpleChartComponent>
private DesignerEditor<JComponent> designerEditor;
// private DesignerEditor<SimpleChartComponent> designerEditor;
//marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false;
private boolean isHovering = 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;
public XChartEditor(BaseChartEditor editor) {
@ -180,12 +187,32 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
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
*/
public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize());
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 boolean
*/
public boolean supportSetEnable(){
return false;
}
/**
* data属性改变触发其他操作
*

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

@ -4,6 +4,7 @@
package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.AdapterBus;
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.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -32,6 +34,7 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
@ -72,12 +75,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
add(editor, BorderLayout.CENTER);
}
if (initSize.width == 0) {
initSize.width = this.initEditorSize().width;
}
if (initSize.height == 0) {
initSize.height = this.initEditorSize().height;
}
setInitSize(initSize);
this.setPreferredSize(initSize);
this.setSize(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 设计界面组件
*@return 工具界面
*/
@Override
public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) {
if (!BaseUtils.isAuthorityEditing()) {
if (isDedicateContainer()) {
@ -381,10 +392,20 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 控件树不显示此组件
* @param path 控件树list
*/
public void notShowInComponentTree(ArrayList<Component> path) {
@Override
public void notShowInComponentTree(List<Component> path) {
return;
}
/**
* 获取其在控件树上可见父层
* @return 组件
*/
@Override
public Component getParentShow(){
return this.getParent();
}
/**
* 重置组件的名称
* @param name 名称
@ -678,6 +699,15 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
// 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;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @author jim
@ -17,7 +17,7 @@ public interface XCreatorTools {
* 控件树不显示此组件
* @param path 控件树list
*/
void notShowInComponentTree(ArrayList<Component> path);
void notShowInComponentTree(List<Component> path);
/**
* 重置组件的名称
@ -54,5 +54,11 @@ public interface XCreatorTools {
* @return 是则返回true
*/
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 FormDesigner designer;
private static BufferedImage DEFAULT_BACKGROUND;
private boolean isHovering = false;
static{
try{
@ -122,7 +123,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
if (editor.getFitStateInPC() == 0) {
editor.setReportFitAttr(null);
}
ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : editor.getReportFitAttr();
ReportFitAttrProvider reportFit = editor.getReportFitAttr();
if(fitAttr != null){
reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr;
}
ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit;
PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr);
if (editor.getReportFitAttr() == null) {
editor.setReportFitInPc(processor.getFitStateInPC(fitAttr));
@ -211,6 +216,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* @param display 是否
*/
public void displayCoverPane(boolean display){
isHovering = display;
coverPanel.setVisible(display);
coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight());
editor.repaint();
@ -227,6 +233,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return coverPanel;
}
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if (!isHovering) {
super.paintBorder(g, bounds);
}
}
/**
* 初始化大小
* @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() {
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
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
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;
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.ComponentAdapter;
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.creator.cardlayout.XWTabFitLayout;
import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget;
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.IOUtils;
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.event.ContainerEvent;
import java.awt.event.MouseEvent;
@ -42,6 +50,10 @@ public class XWAbsoluteLayout extends XLayoutContainer {
private static final int EDIT_BTN_HEIGHT = 24;
private int minWidth = WLayout.MIN_WIDTH;
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%时的计算
protected double containerPercent = 1.0;
@ -437,15 +449,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(XCreatorConstants.COVER_COLOR);
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.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(
image,
(x + w / 2 - 23),
@ -455,9 +470,35 @@ public class XWAbsoluteLayout extends XLayoutContainer {
null,
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);
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;
}
/**
* 编辑状态的时候需要重新绘制下边框
*
*/
@Override
public void paintBorder(Graphics g, Rectangle bounds) {
XCreator childCreator = getEditingChildCreator();
if (childCreator != null) {
childCreator.paintBorder(g, bounds);
}
}
/**
* 将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.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.form.ui.CardSwitchButton;
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.
@ -35,9 +36,11 @@ public class TabMoveAction extends FormUndoableAction {
moveTabAction(xwCardTagLayout, currentButton, xCurrentTab, currentTab);
xwCardTagLayout.setSwitchingTab(false);
xwCardTagLayout.doLayout();
FormHierarchyTreePane.getInstance().refreshDockingView();
}catch (Exception e){
xwCardTagLayout.setSwitchingTab(false);
FineLoggerFactory.getLogger().error(e.getMessage());
FRLogger.getLogger().error(e.getMessage());
return false;
}
return true;

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

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

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

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

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

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

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

@ -3,22 +3,38 @@
*/
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.GraphHelper;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRCardMainBorderLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
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.WBorderLayout;
import com.fr.form.ui.container.WCardLayout;
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.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
@ -27,9 +43,11 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
/**
* card布局主体框架
@ -38,17 +56,17 @@ import java.util.ArrayList;
*
* @date: 2014-12-9-下午9:59:31
*/
public class XWCardMainBorderLayout extends XWBorderLayout{
public class XWCardMainBorderLayout extends XWBorderLayout {
private static final int CENTER = 1;
private static final int 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 NORMAL_STYLE = 1;
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
private static final int EDIT_BTN_WIDTH = 75;
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
*
*/
@Override
public WCardMainBorderLayout toData() {
return (WCardMainBorderLayout) super.toData();
}
@ -84,15 +103,86 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
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) {
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 表单设计器
*/
@Override
public void stopAddingState(FormDesigner designer){
designer.stopAddingState();
return;
@ -119,7 +209,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
public XWCardTitleLayout getTitlePart(){
Component[] components = this.getComponents();
for(Component component : components){
if(component instanceof XWCardTitleLayout){
if(component instanceof XWCardTitleLayout){
return (XWCardTitleLayout)component;
}
}
@ -141,8 +231,14 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 控件树不显示此组件
* @param path 控件树list
*/
public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(LAYOUT_INDEX);
@Override
public void notShowInComponentTree(List<Component> path) {
return;
}
@Override
public int getShowXCreatorCount() {
return CARDMAINLAYOUT_CHILD_COUNT;
}
@Override
@ -160,7 +256,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 重新调整子组件的宽度
* @param width 宽度
*/
public void recalculateChildWidth(int width){
@Override
public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList();
int size = childrenList.size();
if (size > 0) {
@ -191,7 +288,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* 重新调整子组件的高度
* @param height 高度
*/
public void recalculateChildHeight(int height){
@Override
public void recalculateChildHeight(int height){
ArrayList<?> childrenList = this.getTargetChildrenList();
int size = childrenList.size();
if (size > 0) {
@ -223,6 +321,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
}
@Override
public void paint(Graphics g) {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
@ -235,15 +334,19 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(XCreatorConstants.COVER_COLOR);
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.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(
image,
(x + w / 2 - 23),
@ -253,9 +356,18 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
null,
this
);
g2d.setColor(Color.BLACK);
g2d.setColor(Color.WHITE);
//画编辑文字
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5);
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM);
}
}
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if (!isMouseEnter) {
super.paintBorder(g, bounds);
}
}
@ -265,7 +377,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
@Override
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = e.getButton() == MouseEvent.BUTTON1 &&
@ -289,43 +402,57 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
*/
@Override
public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this;
}
}
@Override
public int getIndexOfChild(Object child) {
XWCardTitleLayout titlePart = this.getTitlePart();
return titlePart.getIndexOfChild(child);
}
/**
* data属性改变触发其他操作
*
*/
@Override
public void firePropertyChange(){
getCardPart().initStyle();
return;
}
public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){
XWCardTitleLayout xwCardTitleLayout = getTitlePart();
int titleSize = getTitleWidth();
xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition);
Rectangle parentBounds = new Rectangle(xwCardTitleLayout.getBounds());
switch (wTabDisplayPosition){
case TOP_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.NORTH);
this.addTitlePart(xwCardTitleLayout, WBorderLayout.NORTH);
parentBounds.height = titleSize;
break;
case LEFT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.WEST);
this.addTitlePart(xwCardTitleLayout, WBorderLayout.WEST);
parentBounds.width = titleSize;
break;
case BOTTOM_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.SOUTH);
this.addTitlePart(xwCardTitleLayout, WBorderLayout.SOUTH);
parentBounds.height = titleSize;
break;
case RIGHT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.EAST);
this.addTitlePart(xwCardTitleLayout, WBorderLayout.EAST);
parentBounds.width = titleSize;
break;
default:
break;
}
xwCardTitleLayout.setBounds(parentBounds);
this.addCardPart((XWCardLayout)this.getComponent(0));
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRCardMainBorderLayoutAdapter(this);
}
}

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

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

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

@ -3,11 +3,6 @@
*/
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.ComponentAdapter;
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.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 LAYOUT_INDEX = 0;
private static final int POSISIONT_OFFSET = 1;
/**
* 构造函数
*/
@ -47,19 +53,48 @@ public class XWCardTitleLayout extends XWBorderLayout {
super(widget, initSize);
}
/**
* 初始化组件大小titlePart的宽高可能为0
*/
@Override
public void setInitSize(Dimension initSize){
return;
}
public WTabDisplayPosition 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
*/
@Override
public void convert(){
isRefreshing = true;
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};
for (int i = 0; i < arrs.length; i++) {
Widget wgt = titleLayout.getLayoutWidget(arrs[i]);
@ -139,7 +174,8 @@ public class XWCardTitleLayout extends XWBorderLayout {
*
* @return designer 表单设计器
*/
public void stopAddingState(FormDesigner designer){
@Override
public void stopAddingState(FormDesigner designer){
designer.stopAddingState();
return;
}
@ -182,6 +218,7 @@ public class XWCardTitleLayout extends XWBorderLayout {
return this.getBackupParent().getTopLayout();
}
@Override
public String createDefaultName() {
return "tabpane";
}
@ -191,5 +228,5 @@ public class XWCardTitleLayout extends XWBorderLayout {
public XCreator getXCreator() {
return (XCreator)this.getComponent(1);
}
}

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

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

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

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

8
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 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);
// 布局拖拽时的颜色
@ -43,7 +43,11 @@ public class XCreatorConstants {
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 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);

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

@ -3,11 +3,6 @@
*/
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.design.gui.icombobox.UIComboBox;
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.general.Inter;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* CardTagLayoutBorderPane Pane.
*/
@ -32,7 +32,7 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
protected UIScrollPane initRightBottomPane(){
this.setFontSizeComboBox(new UIComboBox(FRFontPane.FONT_SIZES));
this.setFontNameComboBox(new UIComboBox(Utils.getAvailableFontFamilyNames4Report()));
this.setFontNameComboBox(new UIComboBox(Utils.getAvailableFontFamilyNames4Report()));
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0));
fontSizeTypePane.add(this.getFontSizeComboBox(), BorderLayout.CENTER);
fontSizeTypePane.add(this.getFontNameComboBox(), BorderLayout.EAST);
@ -72,7 +72,7 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
centerPane.add(borderPane, BorderLayout.CENTER);
borderPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 10, 4));
this.setLayoutBorderPreviewPane(new CardTagLayoutBorderPreviewPane(this.getBorderStyle()));
this.setLayoutBorderPreviewPane(new CardTagLayoutBorderPreviewPane(this.getBorderStyle()));
borderPane.add(this.getLayoutBorderPreviewPane(), BorderLayout.CENTER);
@ -92,15 +92,18 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
return;
}
public LayoutBorderStyle update() {
LayoutBorderStyle style = new LayoutBorderStyle();
style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex());
style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle());
style.setColor(this.getCurrentLineColorPane().getColor());
style.setBackground(this.getBackgroundPane().update());
style.setAlpha((float)(this.getNumberDragPane().updateBean()/this.getMaxNumber()));
return style;
public LayoutBorderStyle update() {
LayoutBorderStyle style = new LayoutBorderStyle();
if (this.getBorderStyle() != null) {
style.setStyle(this.getBorderStyle());
}
style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex());
style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle());
style.setColor(this.getCurrentLineColorPane().getColor());
style.setBackground(this.getBackgroundPane().update());
style.setAlpha((float) (this.getNumberDragPane().updateBean() / this.getMaxNumber()));
return style;
}
protected void populateBorderType(){
return;

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

@ -3,7 +3,7 @@ package com.fr.design.gui.xpane;
import com.fr.form.ui.LayoutBorderStyle;
/**
*
*
* @author focus
*
*/
@ -11,4 +11,9 @@ public class CardTagLayoutBorderPreviewPane extends LayoutBorderPreviewPane{
public CardTagLayoutBorderPreviewPane(LayoutBorderStyle borderStyle) {
super(borderStyle,true);
}
@Override
protected void showTitlePreviewPane(){
}
}

38
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.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
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.RoundRectangle2D;
@ -54,7 +57,7 @@ public class LayoutBorderPreviewPane extends JPanel{
add(jp);
}
public LayoutBorderPreviewPane(LayoutBorderStyle borderStyle,boolean isTabLayout) {
public LayoutBorderPreviewPane(LayoutBorderStyle borderStyle, boolean isTabLayout) {
this(borderStyle);
this.isTabLayout = true;
}
@ -74,7 +77,7 @@ public class LayoutBorderPreviewPane extends JPanel{
Background background = borderStyle.getBackground();
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);
} else {
g.setColor(Color.WHITE);
@ -90,13 +93,16 @@ public class LayoutBorderPreviewPane extends JPanel{
int height = borderStyle.getTitle().getFrFont().getSize() + GAP;
jp.setPreferredSize(new Dimension(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.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE);
showTitlePreviewPane();
}
}
protected void showTitlePreviewPane(){
jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE);
}
private class titlePreviewPane extends UITextArea {
private FRFont frFont = null;
@ -134,7 +140,7 @@ public class LayoutBorderPreviewPane extends JPanel{
}
Background background = title.getBackground();
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);
}
GraphHelper.drawString(g2d, paintText, startX1, startY);
@ -145,25 +151,25 @@ public class LayoutBorderPreviewPane extends JPanel{
}
g.setColor(borderStyle.getColor());
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 y = double1.getY() + (line == 1 ? 1 : 2) - line ;
RoundRectangle2D.Double double2 = new RoundRectangle2D.Double(x, y, double1.getWidth() + line, double1.getHeight() + line, 0, 0);
GraphHelper.draw(g,double2, borderStyle.getBorder());
}
private void drawTabBack(Graphics2D g2d,Graphics g,WidgetTitle title,FontMetrics fm,int startX1,int startY){
private void drawTabBack(Graphics2D g2d, Graphics g, WidgetTitle title, FontMetrics fm, int startX1, int startY){
Dimension d = getSize();
String paintText = Inter.getLocText("FR-Designer_Title")+TAB_ZERO;
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);
String rightLabel = Inter.getLocText("FR-Designer_Title")+TAB_ONE;
GraphHelper.drawString(g2d, rightLabel, (d.width/2 - fm.stringWidth(paintText)) / 2+d.width/2, startY);
Background background = title.getBackground();
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);
}
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) {
creator.notShowInComponentTree(path);
}
//绝对布局作为body的时候不显示自适应布局父层
if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) {
if ((parent.getParent() != null)
&& ((XCreator) parent.getParent()).acceptType(XWFitLayout.class)) {
parent = parent.getParent().getParent();
continue;
}
}
parent = parent.getParent();
parent = creator.getParentShow();
}
Object[] components = path.toArray();
return new TreePath(components);
}
private void popupPreviewPane(int popupPosYOnScreen, XCreator comp) {
if (previewPane == null) {
previewPane = new PopupPreviewPane();
@ -245,7 +237,7 @@ public class ComponentTree extends JTree {
previewPane.setVisible(false);
}
if (!previewPane.isVisible()) {
if (!previewPane.isVisible() && comp.getWidth() != 0 && comp.getHeight() != 0) {
previewPane.setComp(comp);
int popupPosY = popupPosYOnScreen - FormHierarchyTreePane.getInstance().getLocationOnScreen().y;
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;
import com.fr.base.GraphHelper;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.IOUtils;
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.
@ -17,14 +31,18 @@ import java.awt.*;
public class CoverPane extends JPanel {
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() {
setLayout(getCoverLayout());
setBackground(null);
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
public Dimension getPreferredSize() {
return new Dimension(60, 24);
@ -32,7 +50,7 @@ public class CoverPane extends JPanel {
};
editButton.setBorderPainted(false);
editButton.setExtraPainted(false);
editButton.setBackground(new Color(176, 196, 222));
editButton.setForeground(Color.WHITE);
add(editButton);
}
@ -86,12 +104,30 @@ public class CoverPane extends JPanel {
public void paint(Graphics g) {
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
g2d.setComposite(composite);
g2d.setColor(Color.WHITE);
g2d.setColor(COVER_COLOR);
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);
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
GraphHelper.draw(g, getPaintBorderBounds(), Constants.LINE_MEDIUM);
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
*/
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 JComponent controlButton = new JComponent() {
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
public void setVisible(boolean 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) {
creator.seleteRelatedComponent(creator);
if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator) && (creator.toData()).isVisible()) {
if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator)) {
designer.makeVisible(creator);
}

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

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -266,6 +267,7 @@ public class FormDesignerUI extends ComponentUI {
bounds.y -= designer.getArea().getVerticalValue();
drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height);
//选中时边框颜色
g.setColor(XCreatorConstants.FORM_BORDER_COLOR);
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
@ -277,7 +279,7 @@ public class FormDesignerUI extends ComponentUI {
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
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.stable.bridge.StableFactory;
import javax.swing.*;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
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;
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.form.ui.container.cardlayout.WTabFitLayout;
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();
if(selectIndex == 0){
wTabFitLayout.setCustomStyle(false);
wTabFitLayout.setInitialBackground(null);
wTabFitLayout.setOverBackground(null);
wTabFitLayout.setClickBackground(null);
tabFitLayout.setCustomStyle(false);
tabFitLayout.setInitialBackground(null);
tabFitLayout.setOverBackground(null);
tabFitLayout.setClickBackground(null);
}else{
wTabFitLayout.setCustomStyle(true);
wTabFitLayout.setInitialBackground((Background) initialBackgroundEditor.getValue());
wTabFitLayout.setOverBackground((Background) overBackgroundEditor.getValue());
wTabFitLayout.setClickBackground((Background)clickBackgroundEditor.getValue());
tabFitLayout.setCustomStyle(true);
tabFitLayout.setInitialBackground((Background) initalBackgroundEditor.getValue());
tabFitLayout.setOverBackground((Background) overBackgroundEditor.getValue());
tabFitLayout.setClickBackground((Background)clickBackgroundEditor.getValue());
}
switchCard();
}
public void populate(WTabFitLayout wTabFitLayout){
if(!wTabFitLayout.isCustomStyle()){
@Override
public void populate(WTabFitLayout tabFitLayout){
if(!tabFitLayout.isCustomStyle()){
backgroundHead.setSelectedIndex(0);
initialBackgroundEditor.setValue(null);
initalBackgroundEditor.setValue(null);
overBackgroundEditor.setValue(null);
clickBackgroundEditor.setValue(null);
}else{
backgroundHead.setSelectedIndex(1);
initialBackgroundEditor.setValue(wTabFitLayout.getInitialBackground());
overBackgroundEditor.setValue(wTabFitLayout.getOverBackground());
clickBackgroundEditor.setValue(wTabFitLayout.getClickBackground());
initalBackgroundEditor.setValue(tabFitLayout.getInitialBackground());
overBackgroundEditor.setValue(tabFitLayout.getOverBackground());
clickBackgroundEditor.setValue(tabFitLayout.getClickBackground());
}
switchCard();
}

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

@ -59,13 +59,14 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
@Override
public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){
bounds.width = w;
creator.setBounds(bounds);
}
@Override
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){
bounds.height = h;
creator.setBounds(bounds);
}
@Override
protected String title4PopupWindow() {
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) {
limitHeight(wabs, h, bounds, rec);
}
creator.setBounds(bounds);
}

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

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

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

@ -1,7 +1,5 @@
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.designer.IntervalConstants;
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.FormSelectionUtils;
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.widget.ui.designer.AbstractDataModify;
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.WBodyLayoutType;
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.report.core.ReportUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
@ -54,7 +51,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
private UISpinner componentIntervel;
private PaddingBoundPane paddingBound;
private AccessibleWLayoutBorderStyleEditor stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
public FRFitLayoutDefinePane(XCreator xCreator) {
super(xCreator);
@ -76,13 +72,9 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
public JPanel createAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new AccessibleWLayoutBorderStyleEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
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);
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), stylePane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
jPanel.add(paddingBound, BorderLayout.CENTER);
jPanel.add(jp2, BorderLayout.NORTH);
@ -143,7 +135,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ReportUtils.getWatermarkFromAttrMarkFile(getCurrentIOFile()));
}
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
@ -158,12 +149,13 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
@Override
public WFitLayout updateBean() {
WFitLayout layout = (WFitLayout) creator.toData();
paddingBound.update(layout);
if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) {
paddingBound.update(layout);
}
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
if(borderStyle != null){
layout.setBorderStyle(borderStyle);
}
updateWatermark();
Item item = (Item) layoutComboBox.getSelectedItem();
Object value = item.getValue();
int state = 0;
@ -195,7 +187,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout}));
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FRLogger.getLogger().error(e.getMessage());
}
//todo 验证下
@ -211,18 +203,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
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) {
int interval = wFitLayout.getCompInterval();
if (value != interval) {

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

@ -25,7 +25,7 @@ import java.awt.event.ActionListener;
/**
* Created by ibm on 2017/8/2.
*/
public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorderLayout> {
public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorderLayout> {
private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor;
private UICheckBox setCarousel;
private UISpinner carouselInterval;
@ -38,7 +38,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
carouselInterval = new UISpinner(0, 20, 1, 0);
carouselInterval = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor();
JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
@ -51,7 +51,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel"));
IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{
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(IntervalPane, BorderLayout.CENTER);
setCarousel.addActionListener(new ActionListener() {
@ -73,9 +73,9 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
@Override
public void populateBean(WCardMainBorderLayout ob) {
WCardLayout cardLayout = ob.getCardPart();
accessibleCardTagWLayoutBorderStyleEditor.setValue(ob.getBorderStyle());
accessibleCardTagWLayoutBorderStyleEditor.setValue(cardLayout.getBorderStyle());
setCarousel.setSelected(cardLayout.isCarousel());
IntervalPane.setVisible(ob.isCarousel());
IntervalPane.setVisible(cardLayout.isCarousel());
carouselInterval.setValue(cardLayout.getCarouselInterval());
}
@ -83,10 +83,10 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
@Override
public WCardMainBorderLayout updateBean() {
WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData();
layout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
WCardLayout wCardLayout = layout.getCardPart();
wCardLayout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
wCardLayout.setCarousel(setCarousel.isSelected());
wCardLayout.setCarouselInterval((int)carouselInterval.getValue());
wCardLayout.setCarouselInterval(carouselInterval.getValue());
return layout;
}
}

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

@ -1,9 +1,10 @@
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.creator.XCreator;
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.foldablepane.UIExpandablePane;
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.TableLayout;
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.widget.ui.designer.AbstractDataModify;
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.cardlayout.WCardTagLayout;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import com.fr.general.cardtag.TemplateStyle;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
@ -33,7 +36,7 @@ import java.awt.Component;
* Created by kerry on 2017/11/16.
*/
public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout> {
private AccessibleImgBackgroundEditor backgroundEditor;
private AccessibleTabPaneBackgroundEditor backgroundEditor;
private FRFontPane frFontPane;
private UIButtonGroup displayPositionGroup;
private UIButtonGroup textDirectionGroup;
@ -47,7 +50,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
backgroundEditor = new AccessibleImgBackgroundEditor();
backgroundEditor = new AccessibleTabPaneBackgroundEditor();
templateStyleEditor = new AccessibleTemplateStyleEditor();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
@ -57,8 +60,27 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font"));
fontLabel.setVerticalAlignment(SwingConstants.TOP);
frFontPane = new FRFontPane();
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray());
frFontPane = new FRFontPane() {
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());
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor},
@ -84,7 +106,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void populateBean(WCardTagLayout ob) {
//标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType());
textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType());
@ -100,14 +122,29 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public WCardTagLayout updateBean() {
//标题背景和字体属性设置在WCardLayout上做兼容
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();
layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue());
layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont));
WCardTagLayout layout = (WCardTagLayout) creator.toData();
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));
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()));
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.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;
}

7
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.WCardTitleLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.BorderFactory;
@ -77,12 +78,12 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify<WTabFitLayout> {
@Override
public void populateBean(WTabFitLayout ob) {
borderStyle.populate(ob);
paddingBoundPane.populate(ob);
componentInterval.setValue(ob.getCompInterval());
if(ob.getCurrentCard() == null){
ob.setCurrentCard(getRelateSwitchButton(ob));
}
borderStyle.populate(ob);
titleField.setText(ob.getCurrentCard().getText());
}
@ -118,7 +119,9 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify<WTabFitLayout> {
public WTabFitLayout updateBean() {
WTabFitLayout layout = (WTabFitLayout) creator.toData();
borderStyle.update(layout);
paddingBoundPane.update(layout);
if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) {
paddingBoundPane.update(layout);
}
int gap = (int)componentInterval.getValue();
setLayoutGap(gap, layout, (XWTabFitLayout)creator);
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.JTable;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
@ -248,10 +249,17 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
}
while (dialog.getParent() != null) {
dialog = dialog.getParent();
if (dialog instanceof SmartInsertSubmitJobListPane) {
((SmartInsertSubmitJobListPane)dialog).showParentDialog();
} else if (dialog instanceof Dialog) {
dialog.setVisible(true);
if (dialog instanceof Dialog) {
//这边需要另起一个线程设置可见,防止阻塞
final Container finalDialog = dialog;
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) {
dialog = dialog.getParent();
if (dialog instanceof SmartInsertSubmitJobListPane) {
((SmartInsertSubmitJobListPane)dialog).hideParentDialog();
} else if (dialog instanceof Dialog) {
if (dialog instanceof Dialog) {
// 条件属性中添加的控件的话有两层dialog,需要都隐藏
dialog.setVisible(false);
}
}
}
/**
* 检测是否合法
* @throws Exception

Loading…
Cancel
Save