Browse Source

Merge pull request #632 in BA/design from ~KERRY/design:dev to dev

* commit '3e1bf1e4bac1eafd54054d69df43a8900ab54fbf':
  添加国际化,修改PMD
  REPORT-1384 按钮控件自定义颜色样式
master
superman 8 years ago
parent
commit
3dab55b9d8
  1. 8
      designer_base/src/com/fr/design/locale/designer.properties
  2. 8
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  3. 8
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  4. 8
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  5. 8
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  6. 8
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  7. 53
      designer_base/src/com/fr/design/style/background/BackgroundButtonPane.java
  8. 48
      designer_base/src/com/fr/design/style/background/BackgroundFactory.java
  9. 55
      designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java
  10. 5
      designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java
  11. 79
      designer_base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java
  12. 13
      designer_form/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java

8
designer_base/src/com/fr/design/locale/designer.properties

@ -510,3 +510,11 @@ FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=
FR-Designer_ConfirmDialog_Content=
FR-Designer_ConfirmDialog_Title=
FR-Designer_Background_Null=
FR-Designer_Background_Color=
FR-Designer_Background_Texture=
FR-Designer_Background_Pattern=
FR-Designer_Background_Gradient_Color=
FR-Designer_Background_Image=
FR-Designer_Background_Clear=
FR-Designer_Background_Image_Select=

8
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -510,3 +510,11 @@ FR-Designer_Create_Tree=Build Tree
FR-Designer_Set_Callback_Function=Set Callback Function
FR-Designer_ConfirmDialog_Content=
FR-Designer_ConfirmDialog_Title=
FR-Designer_Background_Null=No Background
FR-Designer_Background_Color=Color
FR-Designer_Background_Texture=Texture
FR-Designer_Background_Pattern=Pattern
FR-Designer_Background_Gradient_Color=Gradient Color
FR-Designer_Background_Image=Image
FR-Designer_Background_Clear=Clear
FR-Designer_Background_Image_Select=Select Picture

8
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -489,3 +489,11 @@ FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=
FR-Designer_ConfirmDialog_Content=
FR-Designer_ConfirmDialog_Title=
FR-Designer_Background_Null=
FR-Designer_Background_Color=
FR-Designer_Background_Texture=
FR-Designer_Background_Pattern=
FR-Designer_Background_Gradient_Color=
FR-Designer_Background_Image=
FR-Designer_Background_Clear=
FR-Designer_Background_Image_Select=

8
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -484,3 +484,11 @@ FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=
FR-Designer_ConfirmDialog_Content=
FR-Designer_ConfirmDialog_Title=
FR-Designer_Background_Null=
FR-Designer_Background_Color=
FR-Designer_Background_Texture=
FR-Designer_Background_Pattern=
FR-Designer_Background_Gradient_Color=
FR-Designer_Background_Image=
FR-Designer_Background_Clear=
FR-Designer_Background_Image_Select=

8
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -514,3 +514,11 @@ FR-Designer_Create_Tree=\u6784\u5EFA\u6811
FR-Designer_Set_Callback_Function=\u8BBE\u7F6E\u56DE\u8C03\u51FD\u6570
FR-Designer_ConfirmDialog_Content=\u662F\u5426\u786E\u5B9A\u5220\u9664tab\u63A7\u4EF6
FR-Designer_ConfirmDialog_Title=FineReport 8.0
FR-Designer_Background_Null=\u6CA1\u6709\u80CC\u666F
FR-Designer_Background_Color=\u989C\u8272
FR-Designer_Background_Texture=\u7EB9\u7406
FR-Designer_Background_Pattern=\u56FE\u6848
FR-Designer_Background_Gradient_Color=\u6E10\u53D8\u8272
FR-Designer_Background_Image=\u56FE\u7247
FR-Designer_Background_Clear=\u6E05\u9664
FR-Designer_Background_Image_Select=\u9009\u62E9\u56FE\u7247

8
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -502,3 +502,11 @@ FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=
FR-Designer_ConfirmDialog_Content=
FR-Designer_ConfirmDialog_Title=
FR-Designer_Background_Null=
FR-Designer_Background_Color=
FR-Designer_Background_Texture=
FR-Designer_Background_Pattern=
FR-Designer_Background_Gradient_Color=
FR-Designer_Background_Image=
FR-Designer_Background_Clear=
FR-Designer_Background_Image_Select=

53
designer_base/src/com/fr/design/style/background/BackgroundButtonPane.java

@ -0,0 +1,53 @@
package com.fr.design.style.background;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Background;
import com.fr.general.Inter;
/**
* Created by ibm on 2017/1/5.
*/
public class BackgroundButtonPane extends BackgroundPane {
public BackgroundButtonPane() {
super();
}
protected void initTabPane() {
int index = 0;
for (Class<? extends Background> key : BackgroundFactory.buttonKindsOfKey()) {
BackgroundUIWrapper wrapper = BackgroundFactory.getButtonWrapper(key);
wrapper.setIndex(index++);
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
}
}
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) {
return BackgroundFactory.getButtonWrapper(background == null ? null : background.getClass());
}
protected BackgroundDetailPane getTabItemPane(Background background, int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
quickPane = BackgroundFactory.createButtonIfAbsent(background == null ? null : background.getClass());
quickPane.addChangeListener(backgroundChangeListener);
cacheMap.put(index, quickPane);
}
tabbedPane.setComponentAt(index, quickPane);
tabbedPane.setSelectedIndex(index);
return quickPane;
}
protected BackgroundDetailPane getTabItemPaneByIndex(int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
quickPane = BackgroundFactory.createButtonIfAbsent(index);
tabbedPane.setComponentAt(index, quickPane);
cacheMap.put(index, quickPane);
quickPane.addChangeListener(backgroundChangeListener);
}
return quickPane;
}
}

48
designer_base/src/com/fr/design/style/background/BackgroundFactory.java

@ -3,7 +3,6 @@ package com.fr.design.style.background;
import com.fr.base.background.*;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.BackgroundQuickUIProvider;
import com.fr.design.fun.BackgroundUIProvider;
import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.design.style.background.impl.*;
@ -21,6 +20,7 @@ public class BackgroundFactory {
private static Map<Class<? extends Background>, BackgroundUIWrapper> map = new LinkedHashMap<>();
private static Map<Class<? extends Background>, BackgroundUIWrapper> browser = new LinkedHashMap<>();
private static Map<Class<? extends Background>, BackgroundUIWrapper> button = new LinkedHashMap<>();
static {
registerUniversal(map);
@ -29,29 +29,38 @@ public class BackgroundFactory {
registerBrowserImageBackground(browser);
registerExtra(map);
registerExtra(browser);
registerButtonBackground(button);
}
private static void registerUniversal(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(null, BackgroundUIWrapper.create()
.setType(NullBackgroundPane.class).setTitle(Inter.getLocText("Background-Null")));
.setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null")));
map.put(ColorBackground.class, BackgroundUIWrapper.create()
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("Color")));
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color")));
map.put(TextureBackground.class, BackgroundUIWrapper.create()
.setType(TextureBackgroundPane.class).setTitle(Inter.getLocText("Background-Texture")));
.setType(TextureBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Texture")));
map.put(PatternBackground.class, BackgroundUIWrapper.create()
.setType(PatternBackgroundPane.class).setTitle(Inter.getLocText("Background-Pattern")));
.setType(PatternBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Pattern")));
map.put(GradientBackground.class, BackgroundUIWrapper.create()
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("Gradient-Color")));
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color")));
}
private static void registerImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("Image")));
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
}
private static void registerBrowserImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("Image")));
.setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
}
private static void registerButtonBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map){
map.put(ColorBackground.class, BackgroundUIWrapper.create()
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color")));
map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageButtonBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
}
private static void registerExtra(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
@ -85,6 +94,29 @@ public class BackgroundFactory {
return new NullBackgroundPane();
}
public static Set<Class<? extends Background>> buttonKindsOfKey() {
return button.keySet();
}
public static BackgroundUIWrapper getButtonWrapper(Class<? extends Background> category) {
return button.get(category);
}
public static BackgroundDetailPane createButtonIfAbsent(Class<? extends Background> category) {
BackgroundUIWrapper wrapper = button.get(category);
return createByWrapper(wrapper);
}
public static BackgroundDetailPane createButtonIfAbsent(int index) {
for (BackgroundUIWrapper wrapper : button.values()) {
if (wrapper.getIndex() == index) {
return createByWrapper(wrapper);
}
}
return new NullBackgroundPane();
}
public static Set<Class<? extends Background>> browserKindsOfKey() {
return browser.keySet();
}

55
designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java

@ -28,16 +28,16 @@ import java.io.File;
*/
public class ImageBackgroundPane extends BackgroundDetailPane {
private ImagePreviewPane previewPane = null;
protected ImagePreviewPane previewPane = null;
private Style imageStyle = null;
private ChangeListener changeListener = null;
private ImageFileChooser imageFileChooser = null;
private UILabel imageSizeLabel = new UILabel();
protected UILabel imageSizeLabel = new UILabel();
protected JRadioButton defaultRadioButton = null;
protected JRadioButton tiledRadioButton = null;
private JRadioButton extendRadioButton = null;
private JRadioButton adjustRadioButton = null;
protected UIRadioButton defaultRadioButton = null;
protected UIRadioButton tiledRadioButton = null;
private UIRadioButton extendRadioButton = null;
private UIRadioButton adjustRadioButton = null;
public ImageBackgroundPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -46,21 +46,27 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.add(previewContainerPane, BorderLayout.CENTER);
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preview"));
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Preview"));
previewOwnerPane.setLayout(new BorderLayout());
previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER);
previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST);
previewPane = new ImagePreviewPane();
previewOwnerPane.add(new JScrollPane(previewPane));
previewPane.addChangeListener(imageSizeChangeListener);
// init image file chooser.
imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false);
}
public JPanel initSelectFilePane(){
JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane();
previewContainerPane.add(selectFilePane, BorderLayout.EAST);
selectFilePane.setBorder(BorderFactory.createEmptyBorder(8, 2, 4, 0));
UIButton selectPictureButton = new UIButton(
Inter.getLocText("Image-Select_Picture"));
Inter.getLocText("FR-Designer_Background_Image_Select"));
selectFilePane.add(selectPictureButton, BorderLayout.NORTH);
selectPictureButton.setMnemonic('S');
selectPictureButton.addActionListener(selectPictureActionListener);
@ -68,10 +74,10 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
selectFilePane.add(layoutPane, BorderLayout.CENTER);
//布局
defaultRadioButton = new UIRadioButton(Inter.getLocText("Default"));
tiledRadioButton = new UIRadioButton(Inter.getLocText("Image-Titled"));
extendRadioButton = new UIRadioButton(Inter.getLocText("Image-Extend"));
adjustRadioButton = new UIRadioButton(Inter.getLocText("Image-Adjust"));
defaultRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-StyleAlignment_Layout_Default"));
tiledRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-StyleAlignment_Layout_Image_Titled"));
extendRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-StyleAlignment_Layout_Image_Extend"));
adjustRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-StyleAlignment_Layout_Image_Adjust"));
defaultRadioButton.addActionListener(layoutActionListener);
tiledRadioButton.addActionListener(layoutActionListener);
@ -79,7 +85,7 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
adjustRadioButton.addActionListener(layoutActionListener);
JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15));
for (JRadioButton button : imageLayoutButtons()) {
for (UIRadioButton button : imageLayoutButtons()) {
jp.add(button);
}
layoutPane.add(jp);
@ -91,14 +97,11 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
layoutBG.add(adjustRadioButton);
defaultRadioButton.setSelected(true);
// init image file chooser.
imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false);
return selectFilePane;
}
protected JRadioButton[] imageLayoutButtons() {
return new JRadioButton[]{
protected UIRadioButton[] imageLayoutButtons() {
return new UIRadioButton[]{
defaultRadioButton,
tiledRadioButton,
extendRadioButton,
@ -121,8 +124,7 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
CoreGraphHelper.waitForImage(image);
previewPane.setImage(image);
setImageStyle();
previewPane.setImageStyle(imageStyle);
imageStyleRepaint();
previewPane.repaint();
} else {
previewPane.setImage(null);
@ -133,6 +135,11 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
}
};
public void imageStyleRepaint(){
setImageStyle();
previewPane.setImageStyle(imageStyle);
}
private void setImageStyle() {
if (tiledRadioButton.isSelected()) {
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED);

5
designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java

@ -1,5 +1,6 @@
package com.fr.design.style.background.impl;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.stable.ArrayUtils;
import javax.swing.*;
@ -15,9 +16,9 @@ public class ImageBackgroundPane4Browser extends ImageBackgroundPane {
}
@Override
protected JRadioButton[] imageLayoutButtons() {
protected UIRadioButton[] imageLayoutButtons() {
return (JRadioButton[]) ArrayUtils.addAll(super.imageLayoutButtons(), new JRadioButton[] {
return (UIRadioButton[]) ArrayUtils.addAll(super.imageLayoutButtons(), new UIRadioButton[] {
defaultRadioButton,
tiledRadioButton,
});

79
designer_base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java

@ -0,0 +1,79 @@
package com.fr.design.style.background.impl;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.general.Background;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by ibm on 2017/1/5.
*/
public class ImageButtonBackgroundPane extends ImageBackgroundPane {
private UIButton chooseButton;
private UIButton clearButton;
public ImageButtonBackgroundPane(){
super();
Style imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER);
previewPane.setImageStyle(imageStyle);
}
public JPanel initSelectFilePane(){
JPanel choosePane = new JPanel(new BorderLayout(0, 10));
choosePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
JPanel choosePane1 = new JPanel(new BorderLayout(0, 10));
initButton();
choosePane.add(chooseButton, BorderLayout.NORTH);
choosePane1.add(clearButton,BorderLayout.NORTH);
choosePane.add(choosePane1,BorderLayout.CENTER);
imageSizeLabel.setHorizontalAlignment(SwingConstants.CENTER);
choosePane1.add(imageSizeLabel,BorderLayout.CENTER);
this.add(choosePane,BorderLayout.EAST);
return choosePane;
}
private void initButton() {
chooseButton = new UIButton(Inter.getLocText("FR-Designer_Background_Image_Select"));
chooseButton.addActionListener(selectPictureActionListener);
clearButton = new UIButton(Inter.getLocText("FR-Designer_Background_Clear"));
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
previewPane.setImage(null);
previewPane.repaint();
}
});
}
public void imageStyleRepaint(){
}
public void populate(Background background) {
if(background != null && background instanceof ImageBackground){
ImageBackground imageBackground = (ImageBackground) background;
if(imageBackground.getImage() != null) {
previewPane.setImage(imageBackground.getImage());
}
}
}
public Background update() {
if(previewPane.getImage() == null) {
return null;
}
return new ImageBackground(previewPane.getImage());
}
}

13
designer_form/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java

@ -1,17 +1,16 @@
package com.fr.design.mainframe.widget.accessibles;
import java.awt.Dimension;
import javax.swing.SwingUtilities;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ColorBackground;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.frpane.ImgChoosePane;
import com.fr.design.style.background.BackgroundButtonPane;
import com.fr.general.Background;
public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
private ImgChoosePane choosePane;
private BackgroundButtonPane choosePane;
public AccessibleImgBackgroundEditor() {
super(new BackgroundWrapper());
@ -20,7 +19,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
@Override
protected void showEditorPane() {
if (choosePane == null) {
choosePane = new ImgChoosePane();
choosePane = new BackgroundButtonPane();
choosePane.setPreferredSize(new Dimension(600, 400));
}
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
@ -32,7 +31,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
fireStateChanged();
}
});
choosePane.populate(getValue() instanceof ImageBackground ? (ImageBackground) getValue() : null);
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
dlg.setVisible(true);
}
}
Loading…
Cancel
Save