Browse Source

Merging in latest from upstream (DESIGN/design:refs/heads/feature/10.0)

* commit '908769c762731b829990242ca611adf2856e11f4':
  代码修改
  REPORT-35149 预定义样式优化及与图表统一
research/11.0
Bjorn 4 years ago
parent
commit
7297416405
  1. 24
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 4
      designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java
  3. 1
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java
  4. 24
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java
  5. 225
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java
  6. 332
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java
  7. 2
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java
  8. 25
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java
  9. 130
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java
  10. 2
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java
  11. 12
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  12. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  13. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  14. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  15. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  16. 4
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  17. 2
      designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java
  18. 10
      designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java
  19. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  20. 4
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  21. 3
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java
  22. 3
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java
  23. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ComponentStyle.java
  24. 8
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java
  25. 15
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  26. 15
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  27. 17
      designer-realize/src/main/java/com/fr/design/actions/cell/GlobalStyleMenuDef.java
  28. 5
      designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java
  29. 7
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java
  30. 4
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  31. 17
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

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

@ -82,8 +82,11 @@ import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager; import javax.swing.undo.UndoManager;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -96,6 +99,8 @@ import java.awt.BorderLayout;
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件) * 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/ */
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy { public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy {
private static final int PREDEFINED_ICON_WIDTH = 27;
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000; private static final int PREFIX_NUM = 3000;
private FILE editingFILE = null; private FILE editingFILE = null;
@ -809,7 +814,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false; return false;
} }
try { try {
this.getTarget().resetPreferenceStyle(this.getTemplatePredefinedStyle()); this.getTarget().setPredefinedStyleName(this.getTemplatePredefinedStyle(), false);
this.getTarget().export(editingFILE.asOutputStream()); this.getTarget().export(editingFILE.asOutputStream());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -1309,17 +1314,19 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
for (DesignerFrameUpButtonProvider provider : providers) { for (DesignerFrameUpButtonProvider provider : providers) {
uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState())); uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState()));
} }
UIButton predefinedBtn = createPreferenceButton(); UIButton predefinedBtn = createPreDefinedButton();
if (predefinedBtn != null) { if (predefinedBtn != null) {
uiButtons = ArrayUtils.addAll(uiButtons, new UIButton[]{predefinedBtn}); uiButtons = ArrayUtils.addAll(uiButtons, new UIButton[]{predefinedBtn});
} }
return uiButtons; return uiButtons;
} }
protected UIButton createPreferenceButton(){ private UIButton createPreDefinedButton() {
UIButton preferenceButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); UIButton preferenceButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png"));
preferenceButton.setToolTipText("预定义样式按钮"); preferenceButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style"));
preferenceButton.setText(getTemplatePredefinedStyle()); preferenceButton.setText(getTemplatePredefinedStyle());
preferenceButton.setAlignmentX(SwingConstants.LEFT);
setPredefinedButtonSize(preferenceButton);
preferenceButton.set4ToolbarButton(); preferenceButton.set4ToolbarButton();
preferenceButton.addActionListener(new ActionListener() { preferenceButton.addActionListener(new ActionListener() {
@Override @Override
@ -1335,9 +1342,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return preferenceButton; return preferenceButton;
} }
private void setPredefinedButtonSize(UIButton predefinedBtn) {
String text = predefinedBtn.getText();
FontMetrics metrics = predefinedBtn.getFontMetrics(predefinedBtn.getFont());
predefinedBtn.setPreferredSize(new Dimension(Math.min(metrics.stringWidth(text) + PREDEFINED_ICON_WIDTH, 100), 20));
}
public void resetPredefinedStyle(String styleName, UIButton predefinedBtn) { public void resetPredefinedStyle(String styleName, UIButton predefinedBtn) {
this.getTarget().resetPreferenceStyle(styleName); this.getTarget().setPredefinedStyleName(styleName, true);
predefinedBtn.setText(getTemplatePredefinedStyle()); predefinedBtn.setText(getTemplatePredefinedStyle());
setPredefinedButtonSize(predefinedBtn);
this.fireTargetModified(); this.fireTargetModified();
this.repaint(); this.repaint();
} }

4
designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java

@ -11,13 +11,13 @@ public enum PatternStyle {
DARK_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Dark_Pattern")) { DARK_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Dark_Pattern")) {
@Override @Override
public PredefinedStyle getPredefinedStyle() { public PredefinedStyle getPredefinedStyle() {
return PredefinedPatternStyleManager.getInstance().getDarkMode(); return PredefinedPatternStyleManager.INSTANCE.getDarkMode();
} }
}, },
LIGHT_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Light_Pattern")) { LIGHT_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Light_Pattern")) {
@Override @Override
public PredefinedStyle getPredefinedStyle() { public PredefinedStyle getPredefinedStyle() {
return PredefinedPatternStyleManager.getInstance().getLightMode(); return PredefinedPatternStyleManager.INSTANCE.getLightMode();
} }
}; };

1
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java

@ -98,6 +98,7 @@ public class PredefinedStyleBlock extends JPanel {
PredefinedStylePreviewPane content = new PredefinedStylePreviewPane(0.387, 0.384); PredefinedStylePreviewPane content = new PredefinedStylePreviewPane(0.387, 0.384);
content.setPreferredSize(new Dimension(200, 125)); content.setPreferredSize(new Dimension(200, 125));
UILabel label = new UILabel(previewObject.getStyleName()); UILabel label = new UILabel(previewObject.getStyleName());
label.setToolTipText(previewObject.getStyleName());
label.setPreferredSize(new Dimension(167, 25)); label.setPreferredSize(new Dimension(167, 25));

24
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java

@ -1,8 +1,8 @@
package com.fr.design.mainframe.predefined.ui; package com.fr.design.mainframe.predefined.ui;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.predefined.PredefinedStyle; import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.predefined.PredefinedStyleConfig; import com.fr.config.predefined.PredefinedStyleConfig;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
@ -11,11 +11,11 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.detail.CellStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.ChartStyleSettingPane; import com.fr.design.mainframe.predefined.ui.detail.ChartStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.ColorFillStylePane; import com.fr.design.mainframe.predefined.ui.detail.ColorFillStylePane;
import com.fr.design.mainframe.predefined.ui.detail.ComponentStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.PredefinedBackgroundSettingPane; import com.fr.design.mainframe.predefined.ui.detail.PredefinedBackgroundSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.ComponentStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.CellStyleListControlPane;
import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane; import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -36,7 +36,7 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
private PredefinedStylePreviewPane previewPane; private PredefinedStylePreviewPane previewPane;
private UITextField styleNameField; private UITextField styleNameField;
private PredefinedBackgroundSettingPane backgroundSettingPane; private PredefinedBackgroundSettingPane backgroundSettingPane;
private CellStyleSettingPane cellStyleSettingPane; private CellStyleListControlPane cellStyleSettingPane;
private ComponentStyleSettingPane componentStyleSettingPane; private ComponentStyleSettingPane componentStyleSettingPane;
private ChartStyleSettingPane chartStyleSettingPane; private ChartStyleSettingPane chartStyleSettingPane;
private PredefinedStyleSelectPane selectPane; private PredefinedStyleSelectPane selectPane;
@ -44,6 +44,8 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
private boolean isPopulating = false; private boolean isPopulating = false;
private UITabbedPane uiTabbedPane; private UITabbedPane uiTabbedPane;
private boolean isLightMode = true;
@Override @Override
protected JPanel createContentPane() { protected JPanel createContentPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -167,7 +169,7 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
private JPanel createCellStyleSettingPane() { private JPanel createCellStyleSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
this.cellStyleSettingPane = new CellStyleSettingPane(this); this.cellStyleSettingPane = new CellStyleListControlPane();
jPanel.add(this.cellStyleSettingPane); jPanel.add(this.cellStyleSettingPane);
return jPanel; return jPanel;
} }
@ -193,6 +195,7 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
public void populate(PredefinedStyle previewObject) { public void populate(PredefinedStyle previewObject) {
isPopulating = true; isPopulating = true;
isLightMode = previewObject.isLightMode();
styleNameField.setText(previewObject.getStyleName()); styleNameField.setText(previewObject.getStyleName());
this.backgroundSettingPane.populateBean(previewObject.getPredefinedBackground()); this.backgroundSettingPane.populateBean(previewObject.getPredefinedBackground());
this.cellStyleSettingPane.populateBean(previewObject.getCellStyleConfig()); this.cellStyleSettingPane.populateBean(previewObject.getCellStyleConfig());
@ -205,6 +208,7 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
public PredefinedStyle update() { public PredefinedStyle update() {
PredefinedStyle predefinedStyle = new PredefinedStyle(); PredefinedStyle predefinedStyle = new PredefinedStyle();
predefinedStyle.setLightMode(isLightMode);
predefinedStyle.setStyleName(this.styleNameField.getText()); predefinedStyle.setStyleName(this.styleNameField.getText());
predefinedStyle.setCellStyleConfig(this.cellStyleSettingPane.updateBean()); predefinedStyle.setCellStyleConfig(this.cellStyleSettingPane.updateBean());
predefinedStyle.setPredefinedBackground(this.backgroundSettingPane.updateBean()); predefinedStyle.setPredefinedBackground(this.backgroundSettingPane.updateBean());
@ -215,11 +219,12 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
} }
public boolean saveStyle() { public boolean saveStyle() {
PredefinedStyle previewObject = null; PredefinedStyle previewObject;
try { try {
previewObject = update(); previewObject = update();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
} }
if (this.styleNameField.isEnabled() && !validateRepeat(previewObject.getStyleName())) { if (this.styleNameField.isEnabled() && !validateRepeat(previewObject.getStyleName())) {
return false; return false;
@ -231,7 +236,7 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
return true; return true;
} }
public boolean saveStyle(PredefinedStyle previewObject) { private boolean saveStyle(PredefinedStyle previewObject) {
PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
if (StringUtils.isEmpty(previewObject.getStyleName())) { if (StringUtils.isEmpty(previewObject.getStyleName())) {
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this), FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this),
@ -239,18 +244,19 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
return false; return false;
} }
config.put(previewObject.getStyleName(), previewObject); config.add(previewObject);
ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config);
selectPane.refreshPane(); selectPane.refreshPane();
return true; return true;
} }
public void saveAsNewStyle(String styleName) { public void saveAsNewStyle(String styleName) {
PredefinedStyle previewObject = null; PredefinedStyle previewObject;
try { try {
previewObject = update(); previewObject = update();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return;
} }
previewObject.setStyleName(styleName); previewObject.setStyleName(styleName);
if (validateRepeat(styleName)) { if (validateRepeat(styleName)) {

225
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java

@ -0,0 +1,225 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.config.predefined.PredefinedCellStyleConfig;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane;
import com.fr.design.menu.ShortCut;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Created by kerry on 2020-09-27
*/
public class CellStyleListControlPane extends JListControlPane {
private boolean namePermitted = true;
public CellStyleListControlPane() {
super();
this.addModNameActionListener(new ModNameActionListener() {
public void nameModed(int index, String oldName, String newName) {
if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) {
return;
}
namePermitted = true;
String[] allNames = nameableList.getAllNames();
allNames[index] = StringUtils.EMPTY;
if (StringUtils.isEmpty(newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index);
return;
}
if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index);
return;
}
populateSelectedValue();
}
});
}
private void showTipDialogAndReset(String content, int index) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(CellStyleListControlPane.this),
content,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
setIllegalIndex(index);
namePermitted = false;
}
@Override
public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePane.class)};
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
protected void initComponentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setCreators(this.createNameableCreators());
initCardPane();
JPanel leftPane = getLeftPane();
JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL);
leftPane.setPreferredSize(new Dimension(70, 0));
jSeparator.setPreferredSize(new Dimension(2, 0));
cardPane.setPreferredSize(new Dimension(238, 0));
cardPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
JPanel mainSplitPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
mainSplitPane.add(leftPane, BorderLayout.WEST);
mainSplitPane.add(jSeparator, BorderLayout.CENTER);
mainSplitPane.add(cardPane, BorderLayout.EAST);
this.add(mainSplitPane, BorderLayout.CENTER);
this.checkButtonEnabled();
}
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
shortCutFactory.addItemShortCut(),
new RemoveItemShortCut4JControlPane(new RemoveItemAction())
};
}
public class RemoveItemShortCut4JControlPane extends ShortCut4JControlPane {
RemoveItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut;
}
@Override
public void checkEnable() {
ListModelElement selectModel = CellStyleListControlPane.this.getSelectedValue();
if (selectModel != null) {
NameObject selectNameObject = (NameObject) selectModel.wrapper;
PredefinedCellStyle cellStyle = (PredefinedCellStyle) (selectNameObject.getObject());
this.shortCut.setEnabled(!cellStyle.isBuiltIn() && !cellStyle.isDefaultStyle());
} else {
this.shortCut.setEnabled(false);
}
}
}
private class RemoveItemAction extends UpdateAction {
RemoveItemAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText(("Fine-Design_Basic_Action_Remove")));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/base/images/cell/control/remove.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
CellStyleListControlPane.this.onRemoveItem();
}
}
class CellStyleNameObjectCreator extends NameObjectCreator {
public CellStyleNameObjectCreator(String menuName, Class clazz, Class<? extends BasicBeanPane> updatePane) {
super(menuName, clazz, updatePane);
}
public Nameable createNameable(UnrepeatedNameHelper helper) {
Constructor<? extends PredefinedCellStyle> constructor = null;
try {
constructor = clazzOfInitCase.getConstructor();
PredefinedCellStyle cellStyle = constructor.newInstance();
cellStyle.setName(menuName);
cellStyle.setStyle(Style.getInstance());
return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle);
} catch (NoSuchMethodException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IllegalAccessException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (InstantiationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (InvocationTargetException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
}
/**
* Populate
*/
public void populateBean(PredefinedCellStyleConfig ob) {
if (ob == null) {
return;
}
List nameStyleList = new ArrayList();
Iterator styleNameIterator = ob.getStyleNameIterator();
while (styleNameIterator.hasNext()) {
String name = (String) styleNameIterator.next();
PredefinedCellStyle tmpStyle = ob.getStyle(name);
if (tmpStyle != null) {
nameStyleList.add(new NameObject(name, tmpStyle));
}
}
NameObject[] nameObjects = new NameObject[nameStyleList.size()];
nameStyleList.toArray(nameObjects);
populate(nameObjects);
}
public PredefinedCellStyleConfig updateBean() {
Nameable[] nameables = this.update();
PredefinedCellStyleConfig styleConfig = new PredefinedCellStyleConfig();
for (int i = 0; i < nameables.length; i++) {
PredefinedCellStyle tmpStyle = (PredefinedCellStyle) ((NameObject) nameables[i]).getObject();
tmpStyle.setName(nameables[i].getName());
styleConfig.addStyle(tmpStyle);
}
return styleConfig;
}
}

332
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java

@ -1,332 +0,0 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.config.predefined.PredefinedCellStyleConfig;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.i18n.Toolkit;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleEditPane;
import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.core.PaintUtils;
import com.fr.stable.Constants;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Created by kerry on 2020-09-01
*/
public class CellStyleSettingPane extends BasicBeanPane<PredefinedCellStyleConfig> {
private StyleListPane styleListPane;
private List<CustomPredefinedStylePane> customStylePaneList = new ArrayList<>();
private CardLayout cardLayout;
private JPanel centerPane;
private PredefinedStyleEditPane editPane;
private CellStylePreviewPane previewPane;
private UIButton removeBtn;
public CellStyleSettingPane(PredefinedStyleEditPane editPane) {
this.editPane = editPane;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(createLeftPane(), BorderLayout.WEST);
this.add(createCenterPane(), BorderLayout.CENTER);
}
private JPanel createLeftPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setPreferredSize(new Dimension(80, 267));
panel.add(createToolPane(), BorderLayout.NORTH);
panel.add(createStyleListPane(), BorderLayout.CENTER);
return panel;
}
private JPanel createToolPane() {
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
UIButton addBtn = new UIButton(BaseUtils.readIcon(IconPathConstants.ADD_POPMENU_ICON_PATH));
addBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
styleListPane.addNewStyle();
}
});
addBtn.setBorderPainted(false);
panel.add(addBtn);
removeBtn = new UIButton(BaseUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH));
removeBtn.setBorderPainted(false);
removeBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
styleListPane.removeStyle();
}
});
panel.add(removeBtn);
return panel;
}
private JPanel createStyleListPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setPreferredSize(new Dimension(80, 249));
styleListPane = new StyleListPane();
jPanel.add(styleListPane);
return jPanel;
}
private JPanel createCenterPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel titlePreviewPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"));
titlePreviewPane.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
previewPane = new CellStylePreviewPane();
previewPane.setPreferredSize(new Dimension(100, 20));
titlePreviewPane.setPreferredSize(new Dimension(230, 45));
titlePreviewPane.add(previewPane);
panel.add(titlePreviewPane, BorderLayout.NORTH);
cardLayout = new CardLayout();
centerPane = new JPanel(cardLayout);
panel.add(centerPane, BorderLayout.CENTER);
return panel;
}
@Override
public void populateBean(PredefinedCellStyleConfig ob) {
styleListPane.populate(ob);
}
@Override
public PredefinedCellStyleConfig updateBean() {
return styleListPane.update();
}
@Override
protected String title4PopupWindow() {
return null;
}
class StyleListPane extends JPanel {
private DefaultListModel defaultListModel;
private JNameEdList styleList;
public StyleListPane() {
defaultListModel = new DefaultListModel();
styleList = new JNameEdList(defaultListModel) {
public Rectangle createRect(Rectangle rect, int iconWidth) {
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
}
};
styleList.setEditable(true);
styleList.addModNameActionListener(new ModNameActionListener() {
public void nameModed(int index, String oldName, String newName) {
if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) {
return;
}
String[] allNames = styleList.getAllNames();
allNames[index] = StringUtils.EMPTY;
if (StringUtils.isEmpty(newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index);
return;
}
if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index);
styleList.setNameAt("请重新命名", index);
return;
}
styleList.repaint();
}
});
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(styleList, BorderLayout.CENTER);
styleList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int selectIndex = styleList.getSelectedIndex();
Object nameable = styleList.getType(selectIndex);
if (nameable == null) {
return;
}
PredefinedCellStyle cellStyle = ((PredefinedCellStyle) nameable);
cardLayout.show(centerPane, styleList.getNameAt(selectIndex));
styleList.stopEditing();
removeBtn.setEnabled(!cellStyle.isBuiltIn());
if (!validateCouldRename(cellStyle)) {
return;
}
if (e.getClickCount() >= 2
&& SwingUtilities.isLeftMouseButton(e)) {
styleList.editItemAt(styleList.getSelectedIndex());
}
}
});
}
private boolean validateCouldRename(PredefinedCellStyle cellStyle) {
return !cellStyle.isBuiltIn();
}
private void showTipDialogAndReset(String content, int index) {
styleList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(StyleListPane.this),
content,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
}
protected boolean isNameRepeated(java.util.List[] list, String name) {
for (int i = 0; i < list.length; i++) {
if (list[i].contains(name)) {
return true;
}
}
return false;
}
public void populate(PredefinedCellStyleConfig ob) {
Iterator<PredefinedCellStyle> iterator = ob.getAllStyles().values().iterator();
while (iterator.hasNext()) {
PredefinedCellStyle entry = iterator.next();
addStyle(entry);
}
reset();
}
private void reset() {
if (defaultListModel.getSize() > 0) {
styleList.setSelectedIndex(0);
removeBtn.setEnabled(false);
cardLayout.show(centerPane, styleList.getNameAt(0));
centerPane.validate();
Object nameable = styleList.getType(0);
if (nameable == null) {
return;
}
PredefinedCellStyle cellStyle = ((PredefinedCellStyle) nameable);
previewPane.refresh(cellStyle.getStyle());
}
}
public PredefinedCellStyleConfig update() {
PredefinedCellStyleConfig config = new PredefinedCellStyleConfig();
for (int i = 0; i < defaultListModel.getSize(); i++) {
String name = styleList.getNameAt(i);
Style style = customStylePaneList.get(i).updateBean();
config.addStyle(new PredefinedCellStyle(name, style));
}
return config;
}
public void addNewStyle() {
String newStyleName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style");
if (isNameRepeated(new List[]{Arrays.asList(styleList.getAllNames())},
newStyleName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newStyleName), 0);
return;
}
PredefinedCellStyle cellStyle = new PredefinedCellStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"), Style.getInstance());
addStyle(cellStyle);
}
public void addStyle(PredefinedCellStyle cellStyle) {
ListModelElement el = new ListCellStyleModelElement(new NameObject(cellStyle.getName(), cellStyle));
defaultListModel.addElement(el);
CustomPredefinedStylePane customPredefinedStylePane = new CustomPredefinedStylePane();
customPredefinedStylePane.populateBean(cellStyle.getStyle());
customPredefinedStylePane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
previewPane.refresh(customPredefinedStylePane.updateBean());
editPane.valueChangeAction();
}
});
centerPane.add(customPredefinedStylePane, cellStyle.getName());
customStylePaneList.add(customPredefinedStylePane);
}
public void removeStyle() {
int selectIndex = styleList.getSelectedIndex();
defaultListModel.remove(selectIndex);
centerPane.remove(customStylePaneList.get(selectIndex));
customStylePaneList.remove(selectIndex);
reset();
}
}
class ListCellStyleModelElement extends com.fr.design.gui.ilist.ListModelElement {
private Nameable nameable;
public ListCellStyleModelElement(Nameable nameable) {
super(nameable);
this.nameable = nameable;
}
@Override
public String toString() {
return this.nameable.getName();
}
}
class CellStylePreviewPane extends JPanel {
private TemplateCellElement ce;
public CellStylePreviewPane() {
ce = new DefaultTemplateCellElement();
ce.setValue(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_Test_Word"));
}
public void refresh(Style style) {
this.ce.setStyle(style);
this.repaint();
}
@Override
public void paint(Graphics g) {
Style.paintBackground((Graphics2D) g, ce.getStyle(), this.getWidth(), this.getHeight());
Style.paintBorder((Graphics2D) g, ce.getStyle(), this.getWidth(), this.getHeight());
PaintUtils.paintGridCellContent((Graphics2D) g, ce, this.getWidth(), this.getHeight(), Constants.FR_PAINT_RESOLUTION);
}
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java

@ -38,7 +38,7 @@ public class GradientDetailPane extends AbstractBackgroundDetailPane<GradientBac
JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel blankJp = new JPanel(); JPanel blankJp = new JPanel();
gradientBar = new GradientBar(4, 150); gradientBar = new GradientBar(4, 145);
blankJp.add(gradientBar); blankJp.add(gradientBar);
gradientPanel.add(gradientBar, BorderLayout.SOUTH); gradientPanel.add(gradientBar, BorderLayout.SOUTH);

25
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java

@ -4,6 +4,8 @@ import com.fr.base.Style;
import com.fr.base.background.ImageBackground; import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground; import com.fr.base.background.ImageFileBackground;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UIRadioButton;
@ -30,8 +32,8 @@ import java.awt.event.ActionListener;
/** /**
* Image background pane. * Image background pane.
*/ */
public class ImageDetailPane extends AbstractBackgroundDetailPane<ImageBackground> { public class ImageDetailPane extends AbstractBackgroundDetailPane<ImageBackground> implements UIObserver {
private UIObserverListener listener;
protected ImagePreviewPane previewPane = null; protected ImagePreviewPane previewPane = null;
private Style imageStyle = null; private Style imageStyle = null;
private ChangeListener changeListener = null; private ChangeListener changeListener = null;
@ -49,6 +51,14 @@ public class ImageDetailPane extends AbstractBackgroundDetailPane<ImageBackgroun
imageFileChooser = new ImageFileChooser(); imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false); imageFileChooser.setMultiSelectionEnabled(false);
previewPane = new ImagePreviewPane(); previewPane = new ImagePreviewPane();
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (listener != null) {
listener.doChange();
}
}
});
} }
public JPanel initSelectFilePane() { public JPanel initSelectFilePane() {
@ -161,6 +171,11 @@ public class ImageDetailPane extends AbstractBackgroundDetailPane<ImageBackgroun
tiledRadioButton.setSelected(true); tiledRadioButton.setSelected(true);
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED);
} }
previewPane.setImageStyle(ImageDetailPane.this.imageStyle);
if (imageBackground.getImage() != null) {
previewPane.setImageWithSuffix(imageBackground.getImageWithSuffix());
previewPane.setImage(imageBackground.getImage());
}
fireChagneListener(); fireChagneListener();
} }
@ -185,6 +200,12 @@ public class ImageDetailPane extends AbstractBackgroundDetailPane<ImageBackgroun
} }
} }
@Override
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
}
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image");

130
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java

@ -1,6 +1,8 @@
package com.fr.design.mainframe.predefined.ui.detail.cell; package com.fr.design.mainframe.predefined.ui.detail.cell;
import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.AttrScrollPane; import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -12,11 +14,16 @@ import com.fr.design.gui.style.AbstractBasicStylePane;
import com.fr.design.gui.style.AlignmentPane; import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.BorderPane; import com.fr.design.gui.style.BorderPane;
import com.fr.design.gui.style.FormatPane; import com.fr.design.gui.style.FormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,9 +35,10 @@ import java.util.List;
* @author zhou * @author zhou
* @since 2012-5-24上午10:36:10 * @since 2012-5-24上午10:36:10
*/ */
public class CustomPredefinedStylePane extends MultiTabPane<Style> { public class CustomPredefinedStylePane extends MultiTabPane<PredefinedCellStyle> {
private Style style; private PredefinedCellStyle cellStyle;
private ChangeListener changeListener; private PreviewArea previewArea;
private boolean populating;
public CustomPredefinedStylePane() { public CustomPredefinedStylePane() {
@ -41,6 +49,14 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
tabPane.setLayout(new GridLayout(1, 3, 0, 0)); tabPane.setLayout(new GridLayout(1, 3, 0, 0));
} }
public static CustomPredefinedStylePane createPredefinedStylePane() {
return new CustomPredefinedStylePane();
}
public static CustomPredefinedStylePane createDefaultPredefinedStylePane() {
return new CustomPredefinedStylePaneNoBorder();
}
/** /**
* @return * @return
*/ */
@ -49,11 +65,6 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
} }
public void addChangeListener(ChangeListener listener) {
this.changeListener = listener;
}
/** /**
* *
*/ */
@ -65,20 +76,24 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
/** /**
* *
*/ */
public void populateBean(Style ob) { public void populateBean(PredefinedCellStyle ob) {
this.style = ob; this.populating = true;
this.cellStyle = ob;
for (int i = 0; i < paneList.size(); i++) { for (int i = 0; i < paneList.size(); i++) {
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob); ((AbstractBasicStylePane) paneList.get(i)).populateBean(ob.getStyle());
previewArea.preview(ob.getStyle());
} }
this.populating = false;
} }
@Override @Override
/** /**
* *
*/ */
public Style updateBean() { public PredefinedCellStyle updateBean() {
this.style = ((AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex())).update(this.style); AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex());
return this.style; this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle()));
return this.cellStyle;
} }
@ -87,7 +102,7 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
* @return * @return
*/ */
public boolean accept(Object ob) { public boolean accept(Object ob) {
return ob instanceof Style; return ob instanceof PredefinedCellStyle;
} }
@Override @Override
@ -100,8 +115,20 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
} }
protected void initLayout() { protected void initLayout() {
this.setLayout(new BorderLayout(0, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(tabPane, BorderLayout.NORTH);
JPanel jPanel = new JPanel();
jPanel.setLayout(new BorderLayout(0, 4));
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new PreviewArea();
previewPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null));
previewPane.add(previewArea, BorderLayout.CENTER);
this.add(previewPane, BorderLayout.NORTH);
this.add(jPanel, BorderLayout.CENTER);
jPanel.add(tabPane, BorderLayout.NORTH);
JPanel attrListenerPane = new AbstractAttrNoScrollPane() { JPanel attrListenerPane = new AbstractAttrNoScrollPane() {
@Override @Override
@ -115,10 +142,13 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
this.addAttributeChangeListener(new AttributeChangeListener() { this.addAttributeChangeListener(new AttributeChangeListener() {
@Override @Override
public void attributeChange() { public void attributeChange() {
if (changeListener != null) { if (populating) {
changeListener.stateChanged(null); return;
}
PredefinedCellStyle cellStyle = updateBean();
if (cellStyle != null) {
previewArea.preview(cellStyle.getStyle());
} }
} }
}); });
BasicScrollPane basicScrollPane = new AttrScrollPane() { BasicScrollPane basicScrollPane = new AttrScrollPane() {
@ -130,15 +160,69 @@ public class CustomPredefinedStylePane extends MultiTabPane<Style> {
return basicScrollPane; return basicScrollPane;
} }
}; };
this.add(attrListenerPane, BorderLayout.CENTER); jPanel.add(attrListenerPane, BorderLayout.CENTER);
} }
@Override @Override
/** /**
* *
*/ */
public void updateBean(Style ob) { public void updateBean(PredefinedCellStyle ob) {
return;
}
private static class CustomPredefinedStylePaneNoBorder extends CustomPredefinedStylePane {
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new AlignmentPane());
return paneList;
}
}
/**
* 预览Style的面板
*
* @author richer
*/
private static class PreviewArea extends JComponent {
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public PreviewArea() {
setPreferredSize(new Dimension(40, 30));
}
public void preview(Style style) {
this.style = style;
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
return; return;
} }
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3);
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
} }

2
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java

@ -143,7 +143,7 @@ public class PredefinedStyleEditDialog extends JDialog {
}); });
this.setSize(new Dimension(300, 120)); this.setSize(new Dimension(300, 130));
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
} }

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

@ -20,6 +20,8 @@ import com.fr.design.mainframe.HelpDialogManager;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.NameLayoutBorderStyle;
import com.fr.form.ui.NamePaddingMargin;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -362,4 +364,14 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return false; return false;
} }
/**
* 初始化组件的预定义信息
*/
public void initWidgetPredefinedInfo(String styleName){
this.toData().setNameMargin(NamePaddingMargin.createPredefinedStyle(styleName));
this.toData().setNameBorderStyle(NameLayoutBorderStyle.createPredefinedStyle(styleName));
initBorderStyle();
}
} }

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

@ -819,9 +819,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
/** /**
* 初始化组件的预定义信息 * 初始化组件的预定义信息
*/ */
public void initWidgetPredefinedInfo(){ public void initWidgetPredefinedInfo(String styleName){
} }
} }

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

@ -378,9 +378,10 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
/** /**
* 初始化组件的预定义信息 * 初始化组件的预定义信息
*/ */
public void initWidgetPredefinedInfo(){ public void initWidgetPredefinedInfo(String styleName){
this.toData().setNameMargin(NamePaddingMargin.createPredefinedStyle(StringUtils.EMPTY)); this.toData().setNameMargin(NamePaddingMargin.createPredefinedStyle(styleName));
this.toData().setNameBorderStyle(NameLayoutBorderStyle.createPredefinedStyle(StringUtils.EMPTY)); this.toData().setNameBorderStyle(NameLayoutBorderStyle.createPredefinedStyle(styleName));
initBorderStyle();
} }

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

@ -141,7 +141,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
/** /**
* 初始化组件的预定义信息 * 初始化组件的预定义信息
*/ */
public void initWidgetPredefinedInfo(){ public void initWidgetPredefinedInfo(String styleName){
this.toData().setNameBackground(NameFormBackground.createPredefinedStyle(StringUtils.EMPTY)); this.toData().setNameBackground(NameFormBackground.createPredefinedStyle(styleName));
} }
} }

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

@ -1347,8 +1347,8 @@ public class XWFitLayout extends XLayoutContainer {
/** /**
* 初始化组件的预定义信息 * 初始化组件的预定义信息
*/ */
public void initWidgetPredefinedInfo(){ public void initWidgetPredefinedInfo(String styleName){
this.toData().setNameBackground(NameFormBackground.createPredefinedStyle(StringUtils.EMPTY)); this.toData().setNameBackground(NameFormBackground.createPredefinedStyle(styleName));
} }
} }

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

@ -646,10 +646,12 @@ public class XWTabFitLayout extends XWFitLayout {
return true; return true;
} }
/** /**
* 初始化组件的预定义信息 * 初始化组件的预定义信息
*/ */
public void initWidgetPredefinedInfo(){ public void initWidgetPredefinedInfo(String styleName){
this.toData().setNameBackground(NameFormBackground.createCustomStyleWithBackground(null)); this.toData().setNameBackground(NameFormBackground.createCustomStyleWithBackground(null));
} }

2
designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java

@ -71,7 +71,7 @@ public class FormPredefinedBackgroundPane extends PredefinedStyleSettingPane<Nam
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return null; return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background");
} }
class PreviewPane extends StyleSettingPreviewPane { class PreviewPane extends StyleSettingPreviewPane {

10
designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java

@ -35,7 +35,7 @@ public class PredefinedComponentStyleSettingPane extends PredefinedStyleSettingP
protected JPanel createPredefinedSettingPane() { protected JPanel createPredefinedSettingPane() {
JPanel jPanel = new JPanel(); JPanel jPanel = new JPanel();
jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
jPanel.add(new UILabel("标题内容")); jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")));
formulaPane = new TinyFormulaPane(); formulaPane = new TinyFormulaPane();
formulaPane.setPreferredSize(new Dimension(158, 30)); formulaPane.setPreferredSize(new Dimension(158, 30));
jPanel.add(formulaPane); jPanel.add(formulaPane);
@ -76,7 +76,7 @@ public class PredefinedComponentStyleSettingPane extends PredefinedStyleSettingP
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return null; return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style");
} }
class StyleSettingPane extends BasicBeanPane<ComponentStyle> { class StyleSettingPane extends BasicBeanPane<ComponentStyle> {
@ -90,18 +90,18 @@ public class PredefinedComponentStyleSettingPane extends PredefinedStyleSettingP
private void initPane() { private void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel frame = FRGUIPaneFactory.createTitledBorderNoGapPane("框架"); JPanel frame = FRGUIPaneFactory.createTitledBorderNoGapPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame"));
frameStylePane = new ComponentFrameStylePane(); frameStylePane = new ComponentFrameStylePane();
frameStylePane.setPreferredSize(new Dimension(233, 183)); frameStylePane.setPreferredSize(new Dimension(233, 183));
frame.add(frameStylePane); frame.add(frameStylePane);
JPanel title = FRGUIPaneFactory.createTitledBorderNoGapPane("标题"); JPanel title = FRGUIPaneFactory.createTitledBorderNoGapPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title"));
titleStylePane = ComponentTitleStylePane.createStyleSettingPane(); titleStylePane = ComponentTitleStylePane.createStyleSettingPane();
titleStylePane.setPreferredSize(new Dimension(233, 140)); titleStylePane.setPreferredSize(new Dimension(233, 140));
title.add(titleStylePane); title.add(titleStylePane);
JPanel margin = FRGUIPaneFactory.createTitledBorderNoGapPane("边距"); JPanel margin = FRGUIPaneFactory.createTitledBorderNoGapPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Base_Margin"));
marginStylePane = new ComponentMarginStylePane(); marginStylePane = new ComponentMarginStylePane();
marginStylePane.setPreferredSize(new Dimension(233, 100)); marginStylePane.setPreferredSize(new Dimension(233, 100));
margin.add(marginStylePane); margin.add(marginStylePane);

5
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -37,10 +37,10 @@ import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider; import com.fr.design.fun.RightSelectionHandlerProvider;
@ -969,8 +969,9 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private void refreshCenter(Widget centerWidget, XLayoutContainer formLayoutContainer) { private void refreshCenter(Widget centerWidget, XLayoutContainer formLayoutContainer) {
// 不存在center块, 说明是新建的模板 // 不存在center块, 说明是新建的模板
if (centerWidget == null) { if (centerWidget == null) {
String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
XLayoutContainer layoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(new WFitLayout("body")); XLayoutContainer layoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(new WFitLayout("body"));
layoutContainer.initWidgetPredefinedInfo(); layoutContainer.initWidgetPredefinedInfo(styleName);
layoutContainer.setSize(LARGE_PREFERRED_SIZE); layoutContainer.setSize(LARGE_PREFERRED_SIZE);
setRootComponent(layoutContainer); setRootComponent(layoutContainer);
formLayoutContainer.add(rootComponent, WBorderLayout.CENTER); formLayoutContainer.add(rootComponent, WBorderLayout.CENTER);

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

@ -3,6 +3,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
@ -93,8 +94,9 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
creatorSource = no.getNameOption().createWidget(); creatorSource = no.getNameOption().createWidget();
} }
if (creatorSource != null) { if (creatorSource != null) {
String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
XCreator xCreator = XCreatorUtils.createXCreator(creatorSource); XCreator xCreator = XCreatorUtils.createXCreator(creatorSource);
xCreator.initWidgetPredefinedInfo(); xCreator.initWidgetPredefinedInfo(styleName);
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
FormDesignerUtils.addWidgetProcessInfo(xCreator.toData()); FormDesignerUtils.addWidgetProcessInfo(xCreator.toData());
lastPressEvent = null; lastPressEvent = null;

3
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java

@ -63,7 +63,8 @@ public class AccessibleBodyBackgroundEditor extends UneditableAccessibleEditor {
return null; return null;
} }
NameFormBackground style = (NameFormBackground) v; NameFormBackground style = (NameFormBackground) v;
return style.isPredefinedStyle() ? "预定义" : "自定义"; return style.usePredefinedStyle() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")
: com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom");
} }
/** /**

3
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java

@ -64,7 +64,8 @@ public class AccessibleBorderStyleEditor extends UneditableAccessibleEditor {
return null; return null;
} }
ComponentStyle style = (ComponentStyle) v; ComponentStyle style = (ComponentStyle) v;
return style.isPredefinedStyle() ? "预定义" : "自定义"; return style.usePredefinedStyle() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined") :
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Custom");
} }
/** /**

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ComponentStyle.java

@ -27,8 +27,8 @@ public class ComponentStyle extends AbstractPredefinedNameStyleProvider {
} }
public boolean isPredefinedStyle() { public boolean usePredefinedStyle() {
return this.nameLayoutBorderStyle.isPredefinedStyle(); return this.nameLayoutBorderStyle.usePredefinedStyle();
} }

8
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java

@ -32,11 +32,13 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor},
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
CRPropertyDescriptor[] extraTableEditor = ((XElementCase) creator).getExtraTableEditor(); CRPropertyDescriptor[] extraTableEditor = ((XElementCase) creator).getExtraTableEditor();
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator);
centerPane.add(panel, BorderLayout.NORTH); centerPane.add(panel, BorderLayout.NORTH);
if (extraTableEditor.length > 0) {
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator);
centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER);
}
return centerPane; return centerPane;
} }
@ -49,7 +51,9 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
protected void populateSubBean(ElementCaseEditor ob) { protected void populateSubBean(ElementCaseEditor ob) {
elementCaseToolBarEditor.setValue(ob.getToolBars()); elementCaseToolBarEditor.setValue(ob.getToolBars());
if (extraPropertyGroupPane != null) {
extraPropertyGroupPane.populate(ob); extraPropertyGroupPane.populate(ob);
} }
}
} }

15
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -60,7 +60,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
watermarkEditor = new AccessibleBodyWatermarkEditor(); watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{ new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), backgroundEditor}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background")), backgroundEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -115,7 +115,6 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) { public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1); layoutCombox.setSelectedIndex(1);
NameFormBackground formBackground = ob.getNameBackground(); NameFormBackground formBackground = ob.getNameBackground();
formBackground.setBackgroundAlphaValue(ob.getBorderStyle().getAlpha());
backgroundEditor.setValue(formBackground); backgroundEditor.setValue(formBackground);
boundPane.populate(); boundPane.populate();
@ -142,16 +141,20 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
} }
LayoutBorderStyle borderStyle = new LayoutBorderStyle(); LayoutBorderStyle borderStyle = new LayoutBorderStyle();
NameFormBackground background = (NameFormBackground) backgroundEditor.getValue(); NameFormBackground background = (NameFormBackground) backgroundEditor.getValue();
if (background != null) { updateBodyBackground(background, borderStyle);
borderStyle.setBackground(background.createRealStyle().getBackground());
borderStyle.setAlpha(background.createRealStyle().getAlpha());
}
layout.setBorderStyle(borderStyle); layout.setBorderStyle(borderStyle);
layout.setNameBackground(background); layout.setNameBackground(background);
updateWatermark(); updateWatermark();
return layout; return layout;
} }
private void updateBodyBackground(NameFormBackground background, LayoutBorderStyle borderStyle) {
if (background != null) {
borderStyle.setBackground(background.createRealStyle().getBackground());
borderStyle.setAlpha(background.getBackgroundAlphaValue());
}
}
private void updateWatermark() { private void updateWatermark() {
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue();
if (watermark != null) { if (watermark != null) {

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

@ -83,7 +83,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
paddingBound = new PaddingBoundPane(); paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane( JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{ new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), stylePane}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background")), stylePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
@ -156,7 +156,6 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
adaptComboBox.setSelectedIndex(ob.getCompState()); adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval()); componentIntervel.setValue(ob.getCompInterval());
NameFormBackground formBackground = ob.getNameBackground(); NameFormBackground formBackground = ob.getNameBackground();
formBackground.setBackgroundAlphaValue(ob.getBorderStyle().getAlpha());
stylePane.setValue(formBackground); stylePane.setValue(formBackground);
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
} }
@ -178,10 +177,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
} }
LayoutBorderStyle borderStyle = new LayoutBorderStyle(); LayoutBorderStyle borderStyle = new LayoutBorderStyle();
NameFormBackground background = (NameFormBackground) stylePane.getValue(); NameFormBackground background = (NameFormBackground) stylePane.getValue();
if (background != null) { updateBodyBackground(background, borderStyle);
borderStyle.setBackground(background.createRealStyle().getBackground());
borderStyle.setAlpha(background.createRealStyle().getAlpha());
}
layout.setBorderStyle(borderStyle); layout.setBorderStyle(borderStyle);
layout.setNameBackground(background); layout.setNameBackground(background);
@ -235,6 +231,13 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
return layout; return layout;
} }
private void updateBodyBackground(NameFormBackground background, LayoutBorderStyle borderStyle) {
if (background != null) {
borderStyle.setBackground(background.createRealStyle().getBackground());
borderStyle.setAlpha(background.getBackgroundAlphaValue());
}
}
private void updateWatermark() { private void updateWatermark() {
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue();
if (watermark != null) { if (watermark != null) {

17
designer-realize/src/main/java/com/fr/design/actions/cell/GlobalStyleMenuDef.java

@ -6,9 +6,13 @@ package com.fr.design.actions.cell;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.NameStyle; import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.predefined.PredefinedStyleConfig;
import com.fr.design.actions.SelectionListenerAction; import com.fr.design.actions.SelectionListenerAction;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
@ -72,14 +76,19 @@ public class GlobalStyleMenuDef extends MenuDef {
public void updateMenu() { public void updateMenu() {
UIMenu createdMenu = this.createJMenu(); UIMenu createdMenu = this.createJMenu();
createdMenu.removeAll(); createdMenu.removeAll();
Iterator iterator = ServerPreferenceConfig.getInstance().getStyleNameIterator(); PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
PredefinedStyle currentStyle = config.getStyle(styleName);
if (currentStyle != null) {
Iterator iterator = config.getStyle(styleName).getCellStyleConfig().getStyleNameIterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String name = (String) iterator.next(); String name = (String) iterator.next();
NameStyle nameStyle = NameStyle.getInstance(name); NameStyle nameStyle = NameStyle.createPredefinedStyle(styleName, name, Style.getInstance());
UpdateAction.UseMenuItem useMenuItem = new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem(); UpdateAction.UseMenuItem useMenuItem = new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem();
useMenuItem.setNameStyle(nameStyle); useMenuItem.setNameStyle(nameStyle);
createdMenu.add(useMenuItem); createdMenu.add(useMenuItem);
} }
}
createdMenu.addSeparator(); createdMenu.addSeparator();
createdMenu.add(new CustomStyleAction(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom"))); createdMenu.add(new CustomStyleAction(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom")));
} }
@ -174,9 +183,9 @@ public class GlobalStyleMenuDef extends MenuDef {
if (StringUtils.isEmpty(this.getName())) { if (StringUtils.isEmpty(this.getName())) {
stylePane.setGlobalStyle(this.getNameStyle()); stylePane.setGlobalStyle(this.getNameStyle());
} else { } else {
stylePane.setGlobalStyle(NameStyle.getInstance(this.getName())); String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
stylePane.setGlobalStyle(NameStyle.createPredefinedStyle(styleName, this.getName(), Style.getInstance()));
} }
stylePane.updateGlobalStyle(getEditingComponent()); stylePane.updateGlobalStyle(getEditingComponent());
CellElementPropertyPane.getInstance().GoToPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")); CellElementPropertyPane.getInstance().GoToPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style"));
return true; return true;

5
designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java

@ -1,6 +1,5 @@
package com.fr.design.actions.server.predefined; package com.fr.design.actions.server.predefined;
import com.fr.design.actions.server.StyleManagerPane;
import com.fr.design.mainframe.predefined.ui.dialog.ServerPredefinedStyleDialog; import com.fr.design.mainframe.predefined.ui.dialog.ServerPredefinedStyleDialog;
import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane; import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -25,7 +24,7 @@ public class ServerPredefinedStyleAction extends SnapChatUpdateAction {
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png")); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png"));
this.generateAndSetSearchText(StyleManagerPane.class.getName()); this.generateAndSetSearchText(ServerPredefinedStylePane.class.getName());
} }
@Override @Override
@ -44,7 +43,7 @@ public class ServerPredefinedStyleAction extends SnapChatUpdateAction {
@Override @Override
public String getMenuName() { public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("服务器预定义样式"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Server_Style");
} }
@Override @Override

7
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java

@ -84,9 +84,10 @@ public class CellPredefinedStyleSettingPane extends PredefinedStyleSettingPane<N
@Override @Override
public void populateBean(NameStyle ob) { public void populateBean(NameStyle ob) {
this.setPopulating(true); this.setPopulating(true);
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
super.populate(ob); super.populate(ob);
PredefinedStyle predefinedStyle = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getStyle(template.getTemplatePredefinedStyle()); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String styleName = template.getTemplatePredefinedStyle();
PredefinedStyle predefinedStyle = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getStyle(styleName);
PredefinedCellStyleConfig config = predefinedStyle.getCellStyleConfig(); PredefinedCellStyleConfig config = predefinedStyle.getCellStyleConfig();
Map<String, PredefinedCellStyle> allStyle = config.getAllStyles(); Map<String, PredefinedCellStyle> allStyle = config.getAllStyles();
this.applicationFormat.clearBoxItems(); this.applicationFormat.clearBoxItems();
@ -95,6 +96,8 @@ public class CellPredefinedStyleSettingPane extends PredefinedStyleSettingPane<N
} }
if (allStyle.containsKey(ob.getName())) { if (allStyle.containsKey(ob.getName())) {
this.applicationFormat.setSelectedItem(ob.getName()); this.applicationFormat.setSelectedItem(ob.getName());
}else {
this.applicationFormat.setSelectedItem(config.getDefaultStyleName());
} }
this.customPredefinedStylePane.populateBean(ob); this.customPredefinedStylePane.populateBean(ob);
this.setPopulating(false); this.setPopulating(false);

4
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -4,6 +4,7 @@ import com.fr.base.BaseFormula;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.Margin; import com.fr.base.Margin;
import com.fr.base.NameStyle;
import com.fr.base.PaperSize; import com.fr.base.PaperSize;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
@ -508,6 +509,9 @@ public class GridUI extends ComponentUI {
double cellWidth = this.tmpRectangle.getWidth(); double cellWidth = this.tmpRectangle.getWidth();
double cellHeight = this.tmpRectangle.getHeight(); double cellHeight = this.tmpRectangle.getHeight();
if (tmpCellElement.getStyle() instanceof NameStyle) {
((NameStyle) tmpCellElement.getStyle()).setPredefinedStyleName(getGlobalPredefinedStyleName());
}
// denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框 // denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框
painter.paintBackground(g2d, report, tmpCellElement, cellWidth - 1, cellHeight - 1); painter.paintBackground(g2d, report, tmpCellElement, cellWidth - 1, cellHeight - 1);

17
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -3,10 +3,13 @@ package com.fr.grid.selection;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.NameStyle; import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.cache.list.IntList; import com.fr.cache.list.IntList;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.predefined.PredefinedStyleConfig;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.cell.CellAttributeAction; import com.fr.design.actions.cell.CellAttributeAction;
import com.fr.design.actions.cell.CellExpandAttrAction; import com.fr.design.actions.cell.CellExpandAttrAction;
@ -28,6 +31,7 @@ import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
@ -476,15 +480,20 @@ public class CellSelection extends Selection {
if (!ServerPreferenceConfig.getInstance().hasStyle()) { if (!ServerPreferenceConfig.getInstance().hasStyle()) {
UIMenu styleMenu = new UIMenu(KeySetUtils.GLOBAL_STYLE.getMenuName()); UIMenu styleMenu = new UIMenu(KeySetUtils.GLOBAL_STYLE.getMenuName());
styleMenu.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cell.png")); styleMenu.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cell.png"));
Iterator iterato = ServerPreferenceConfig.getInstance().getStyleNameIterator(); PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
while (iterato.hasNext()) { String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
String name = (String) iterato.next(); PredefinedStyle currentStyle = config.getStyle(styleName);
if (currentStyle != null) {
Iterator iterator = config.getStyle(styleName).getCellStyleConfig().getStyleNameIterator();
while (iterator.hasNext()) {
String name = (String) iterator.next();
name = GlobalStyleMenuDef.judgeChina(name); name = GlobalStyleMenuDef.judgeChina(name);
NameStyle nameStyle = NameStyle.getInstance(name); NameStyle nameStyle = NameStyle.createPredefinedStyle(styleName, name, Style.getInstance());
UpdateAction.UseMenuItem useMenuItem = new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem(); UpdateAction.UseMenuItem useMenuItem = new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem();
useMenuItem.setNameStyle(nameStyle); useMenuItem.setNameStyle(nameStyle);
styleMenu.add(useMenuItem); styleMenu.add(useMenuItem);
} }
}
styleMenu.addSeparator(); styleMenu.addSeparator();
styleMenu.add(new GlobalStyleMenuDef.CustomStyleAction(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"))); styleMenu.add(new GlobalStyleMenuDef.CustomStyleAction(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")));
popup.add(styleMenu); popup.add(styleMenu);

Loading…
Cancel
Save