Browse Source

Merge branch 'release/10.0' of https://cloud.finedevelop.com/scm/~bjorn/design into release/10.0

feature/big-screen
白岳 4 years ago
parent
commit
f6663d5adf
  1. 7
      designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java
  2. 4
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java
  3. 4
      designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java
  4. 22
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  5. 40
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  6. 21
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java
  7. 86
      designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java
  8. 57
      designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java
  9. 23
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java

7
designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java

@ -18,4 +18,11 @@ public interface CellExpandAttrPanelProvider extends Mutable {
* @return 创建单元格属性-扩展设置中的额外面板
*/
BasicBeanPane<TemplateCellElement> createPanel();
/**
* 是否应该展示
*
* @return return {@code true} if extra panel is displayable
*/
boolean isDisplayable();
}

4
designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java

@ -36,4 +36,8 @@ public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelP
public BasicBeanPane<TemplateCellElement> createPanel() {
return null;
}
public boolean isDisplayable() {
return true;
}
}

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

@ -144,7 +144,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
optionPane.setPreferredSize(new Dimension(0, 0));
optionPane.add(option, "show");
Component[][] components = getComponent(fontPane, centerPane, typePane, optionPane);
Component[][] components = getComponent(fontPane, centerPane, typePane);
this.add(createContentPane(components), BorderLayout.CENTER);
}
@ -158,7 +158,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
}
protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) {
protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) {
return new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane},

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

@ -485,24 +485,30 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void replaceAuthorityEditionPane(JComponent pane) {
propertyItemMap.get(KEY_AUTHORITY_EDITION).replaceContentPane(pane);
}
public JComponent getAuthorityEditionPane() {
return propertyItemMap.get(KEY_AUTHORITY_EDITION).getContentPane();
}
public void replaceConfiguredRolesPane(JComponent pane) {
propertyItemMap.get(KEY_CONFIGURED_ROLES).replaceContentPane(pane);
}
public void replaceKeyPane(String key, JComponent pane) {
propertyItemMap.get(key).replaceContentPane(pane);
public void replaceKeyPane(final String key, final JComponent pane) {
//需要放到 ui 线程中处理
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
propertyItemMap.get(key).replaceContentPane(pane);
}
});
}
public JComponent getConfiguredRolesPane() {
return propertyItemMap.get(KEY_CONFIGURED_ROLES).getContentPane();
}
public void addParameterPane(JComponent paraPane) {
propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane);
}

40
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -5,6 +5,7 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
@ -21,14 +22,14 @@ import com.fr.stable.Constants;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@ -42,6 +43,8 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private Widget widget;
private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz;
private UIComboBox customCombo;
private JPanel settingPane;
private ColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241);
private JPanel commomPane;
@ -62,6 +65,8 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override
public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob);
customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0);
if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
}
@ -83,6 +88,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean();
mobileStyle.setCommonCustom(customCombo.getSelectedIndex() == 1);
mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject());
@ -126,6 +132,23 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
commomPane.setBorder(titledBorder);
this.add(commomPane, BorderLayout.NORTH);
customCombo = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Mobile_Default"), Toolkit.i18nText("Fine-Design_Mobile_Custom")});
customCombo.setSelectedIndex(0);
customCombo.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
customCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean custom = customCombo.getSelectedIndex() == 1;
settingPane.setVisible(custom);
}
});
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Attribute_Settings")), customCombo));
settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
settingPane.setVisible(false);
commomPane.add(settingPane);
createBackgroundPane();
createBorderPane();
createIconSettingPane();
@ -136,7 +159,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH);
JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox);
commomPane.add(backgroundPane);
settingPane.add(backgroundPane);
}
private void createBorderPane() {
@ -146,19 +169,20 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
}
private void createIconSettingPane() {
iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
iconColor.setSelectObject(new Color(31,173,229));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
}
private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane();
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
}
private void createCustomPane() {

21
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
@ -16,7 +17,6 @@ import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
@ -31,7 +31,6 @@ public class MobileStyleFontConfigPane extends JPanel {
public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>();
FONT_SIZES.add(FONT_NONE);
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
@ -39,7 +38,7 @@ public class MobileStyleFontConfigPane extends JPanel {
}
private UIComboBox fontSizeComboBox;
private UIToggleButton underline;
private UIColorButton color;
private UIToggleButton italic;
private UIToggleButton bold;
@ -51,10 +50,10 @@ public class MobileStyleFontConfigPane extends JPanel {
fontSizeComboBox = new UIComboBox();
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes()));
fontSizeComboBox.setSelectedItem(0);
fontSizeComboBox.setSelectedItem(16);
fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setRenderer(new LineCellRenderer());
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
color = new UIColorButton();
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
@ -62,7 +61,7 @@ public class MobileStyleFontConfigPane extends JPanel {
this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{
fontSizeComboBox, underline, italic, bold
fontSizeComboBox, color, italic, bold
};
JPanel buttonPane = new JPanel(new BorderLayout());
@ -73,13 +72,13 @@ public class MobileStyleFontConfigPane extends JPanel {
}
private void setButtonsTips() {
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline"));
color.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold"));
}
private void setButtonsSize(Dimension size) {
underline.setPreferredSize(size);
color.setPreferredSize(size);
italic.setPreferredSize(size);
bold.setPreferredSize(size);
}
@ -87,9 +86,9 @@ public class MobileStyleFontConfigPane extends JPanel {
public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
color.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE);
}
public FRFont updateBean() {
@ -100,8 +99,8 @@ public class MobileStyleFontConfigPane extends JPanel {
FRFont.DEFAULT_FONTNAME,
style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
Color.BLACK,
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE
color.getColor(),
Constants.LINE_NONE
);
}

86
designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java

@ -1,47 +1,50 @@
package com.fr.design.designer.beans.models;
import java.awt.Rectangle;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils;
import java.awt.Rectangle;
import java.util.HashSet;
import java.util.Set;
/**
* 添加状态下的model
*/
public class AddingModel {
// 当前要添加的组件
private XCreator creator;
// 记录当前鼠标的位置信息
private int currentX;
private int currentY;
private boolean added;
public AddingModel(FormDesigner designer, XCreator xCreator) {
String creatorName = getXCreatorName(designer, xCreator);
this.creator = xCreator;
instantiateCreator(designer, creatorName);
instantiateCreator(designer);
// 初始的时候隐藏该组件的图标
currentY = -this.creator.getWidth();
currentX = -this.creator.getHeight();
}
/**
* 待说明
* 初始化创建器
*
* @param designer 设计器
* @param creatorName 组件名
* @param designer 设计器
*/
public void instantiateCreator(FormDesigner designer, String creatorName) {
creator.toData().setWidgetName(creatorName);
public void instantiateCreator(FormDesigner designer) {
renameWidgetName(designer.getTarget(), creator);
ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
adapter.initialize();
creator.addNotify();
@ -56,7 +59,7 @@ public class AddingModel {
currentX = x - (xCreator.getWidth() / 2);
currentY = y - (xCreator.getHeight() / 2);
}
/**
* 隐藏当前组件的图标
*/
@ -64,28 +67,65 @@ public class AddingModel {
currentX = -this.creator.getWidth();
currentY = -this.creator.getHeight();
}
public String getXCreatorName(FormDesigner designer, XCreator x) {
/**
* 防止冲突重命名 XCreator 内部的 widget
*
* @param form 表单
* @param xCreator 创建器
*/
private static void renameWidgetName(Form form, XCreator xCreator) {
Set<String> nameSpace = new HashSet<>();
recursiveRenameWidgetName(form, xCreator, nameSpace);
}
private static void recursiveRenameWidgetName(Form form, XCreator xCreator, Set<String> nameSpace) {
String creatorName = uniqueName(form, xCreator, nameSpace);
if (xCreator.toData() instanceof WTitleLayout) {
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) xCreator.toData(), xCreator.getSize());
xwTitleLayout.resetCreatorName(creatorName);
return;
}
xCreator.resetCreatorName(creatorName);
int count = xCreator.getComponentCount();
for (int a = 0; a < count; a++) {
if (xCreator.getComponent(a) instanceof XCreator) {
XCreator child = (XCreator) xCreator.getComponent(a);
recursiveRenameWidgetName(form, child, nameSpace);
}
}
}
/**
* 组件命名规则
*/
public static String uniqueName(Form form, XCreator x, Set<String> nameSpace) {
String def = x.createDefaultName();
if (x.acceptType(XWParameterLayout.class)) {
return def;
}
int i = 0;
while (designer.getTarget().isNameExist(def + i)) {
String name = def + i;
while (form.isNameExist(name) || nameSpace.contains(name)) {
i++;
name = def + i;
}
return def + i;
return name;
}
public int getCurrentX() {
return currentX;
}
public int getCurrentY() {
return currentY;
}
/**
* 移动组件图标到鼠标事件发生的位置
*

57
designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java

@ -0,0 +1,57 @@
package com.fr.design.designer.beans.models;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.main.Form;
import com.fr.form.ui.ChartEditor;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.beans.IntrospectionException;
public class AddingModelTest {
@Test
public void testInstantiateCreator() throws Exception {
ChartEditor chartEditor = new ChartEditor();
chartEditor.setWidgetName("test01");
XCreator xCreator = new XCreator(chartEditor, new Dimension(20, 20)) {
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[0];
}
@Override
protected JComponent initEditor() {
return null;
}
@Override
protected void initXCreatorProperties() {
}
@Override
public String createDefaultName() {
return "test";
}
};
AddingModel addingModel = new AddingModel(xCreator, 20, 20);
Form form = EasyMock.mock(Form.class);
EasyMock.expect(form.isNameExist("test0")).andReturn(true).once();
EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes();
EasyMock.replay(form);
FormDesigner mock = EasyMock.mock(FormDesigner.class);
EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes();
EasyMock.replay(mock);
addingModel.instantiateCreator(mock);
Assert.assertEquals("test1", xCreator.toData().getWidgetName());
}
}

23
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java

@ -73,6 +73,7 @@ public class CellExpandExtraAttrPane extends JPanel {
}
public void populate(TemplateCellElement cellElement) {
refreshExtraPanel();
this.cellElement = cellElement;
if (extras != null) {
for (BasicBeanPane<TemplateCellElement> extra : extras) {
@ -91,6 +92,17 @@ public class CellExpandExtraAttrPane extends JPanel {
}
private void refresh() {
refreshExtraPanel();
if (this.cellElement != null) {
if (extras != null) {
for (BasicBeanPane<TemplateCellElement> extra : extras) {
extra.populateBean(cellElement);
}
}
}
}
private void refreshExtraPanel() {
this.removeAll();
if (extras == null) {
extras = new ArrayList<>();
@ -99,9 +111,11 @@ public class CellExpandExtraAttrPane extends JPanel {
Set<CellExpandAttrPanelProvider> attrProviders = ExtraDesignClassManager.getInstance().getArray(CellExpandAttrPanelProvider.MARK_STRING);
if (attrProviders != null) {
for (CellExpandAttrPanelProvider attrProvider : attrProviders) {
BasicBeanPane<TemplateCellElement> extra = attrProvider.createPanel();
if (extra != null) {
extras.add(extra);
if (attrProvider.isDisplayable()) {
BasicBeanPane<TemplateCellElement> extra = attrProvider.createPanel();
if (extra != null) {
extras.add(extra);
}
}
}
}
@ -115,9 +129,6 @@ public class CellExpandExtraAttrPane extends JPanel {
double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL};
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, H_GAP, V_GAP);
this.add(content, BorderLayout.CENTER);
if (this.cellElement != null) {
this.populate(cellElement);
}
this.validate();
this.repaint();
}

Loading…
Cancel
Save