Browse Source

CHART-1748 910

master
zheng 7 years ago
parent
commit
cb18b1b97a
  1. 19
      designer-base/src/com/fr/design/actions/core/ActionFactory.java
  2. 2
      designer-chart/src/com/fr/design/chart/ChartDesignerActivator.java
  3. BIN
      designer-chart/src/com/fr/design/images/EmptyChart.png
  4. BIN
      designer-chart/src/com/fr/design/images/us_emptydata.png
  5. BIN
      designer-chart/src/com/fr/design/images/zh_emptydata.png
  6. 46
      designer-chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java
  7. 242
      designer-chart/src/com/fr/design/module/ChartEmptyDataStylePane.java
  8. 6
      designer-realize/src/com/fr/start/Designer.java

19
designer-base/src/com/fr/design/actions/core/ActionFactory.java

@ -50,6 +50,7 @@ public class ActionFactory {
private static ConcurrentMap<Class, Class<? extends QuickEditor>> cellEditorClass = new ConcurrentHashMap<>();
private static UpdateAction chartPreStyleAction = null;
private static UpdateAction chartEmptyDataStyleAction = null;
private static UpdateAction chartMapEditorAction = null;
private ActionFactory() {
@ -159,6 +160,24 @@ public class ActionFactory {
return chartMapEditorAction;
}
/**
* 注册图表的 空数据提示样式.
*
* @param action 注册的图表空数据提示样式action
*/
public static void registerChartEmptyDataStyleAction(UpdateAction action) {
chartEmptyDataStyleAction = action;
}
/**
* 图表空数据提示样式Action
*
* @return 图表空数据提示样式Action
*/
public static UpdateAction getChartEmptyDataStyleAction() {
return chartEmptyDataStyleAction;
}
/**
* 获取图表集合类

2
designer-chart/src/com/fr/design/chart/ChartDesignerActivator.java

@ -6,6 +6,7 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.ChartPropertyPane;
import com.fr.design.module.ChartEmptyDataStyleAction;
import com.fr.design.module.ChartHyperlinkGroup;
import com.fr.design.module.ChartPreStyleAction;
import com.fr.design.module.DesignModuleFactory;
@ -38,6 +39,7 @@ public class ChartDesignerActivator extends Activator {
DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);
ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction());
ActionFactory.registerChartEmptyDataStyleAction(new ChartEmptyDataStyleAction());
ActionFactory.registerChartMapEditorAction(new ChartMapEditorAction());
ActionFactory.registerChartCollection(ChartCollection.class);

BIN
designer-chart/src/com/fr/design/images/EmptyChart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

BIN
designer-chart/src/com/fr/design/images/us_emptydata.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
designer-chart/src/com/fr/design/images/zh_emptydata.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

46
designer-chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java

@ -0,0 +1,46 @@
package com.fr.design.module;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import java.awt.event.ActionEvent;
/**
* Created by mengao on 2017/11/23.
* 空数据配置action
*/
public class ChartEmptyDataStyleAction extends UpdateAction {
public ChartEmptyDataStyleAction() {
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/EmptyChart.png"));
this.setName(Inter.getLocText("FR-Designer_Chart_Empty_Data"));
}
@Override
public void actionPerformed(ActionEvent e) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final ChartEmptyDataStylePane pane = new ChartEmptyDataStylePane();
BasicDialog dialog = pane.showWindow(designerFrame);
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
pane.updateBean();
}
@Override
public void doCancel() {
//直接关闭弹出框
}
});
pane.populateBean();
dialog.setVisible(true);
}
}

242
designer-chart/src/com/fr/design/module/ChartEmptyDataStylePane.java

@ -0,0 +1,242 @@
package com.fr.design.module;
import com.fr.base.BaseUtils;
import com.fr.base.ChartEmptyDataStyleConf;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane;
import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
/**
* Created by mengao on 2017/11/23.
*/
public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private static final int WIDTH = 150;
private static final int HEIGHT = 20;
private static final int FIVE = 5;
private static final int TEN = 10;
private static final int THIRTY = 30;
private static Image DEFAULT_EMPTY_DATA_IMAGE;
private UIButtonGroup emptyData;
private UIRadioButton defaultRadioButton;
private UIRadioButton customRadioButton;
private UIButton selectPictureButton;
private ImagePreviewPane previewPane;
private ImageFileChooser imageFileChooser;
private Image emptyDataImage = DEFAULT_EMPTY_DATA_IMAGE;
private SwingWorker<Void, Void> imageWorker;
static {
DEFAULT_EMPTY_DATA_IMAGE = GeneralContext.isChineseEnv() ? IOUtils.readImage("com/fr/design/images/zh_emptydata.png")
: IOUtils.readImage("com/fr/design/images/us_emptydata.png");
}
@Override
protected JPanel createContentPane() {
JPanel content = new JPanel(new BorderLayout());
content.add(creatNorthPane(), BorderLayout.NORTH);
content.add(creatCenterPane(), BorderLayout.CENTER);
return content;
}
private JPanel creatNorthPane() {
emptyData = new UIButtonGroup(new String[]{Inter.getLocText("Plugin-ChartF_Open"), Inter.getLocText("Plugin-ChartF_Close")});
emptyData.setSelectedIndex(0);
emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
emptyData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkEmptyDataStyle();
repaintPreviewPane();
}
});
UILabel promptContent = new UILabel(Inter.getLocText("FR-Designer_Tip_Content"));
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0);
northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0));
return northPane;
}
private JPanel creatCenterPane() {
JPanel centerPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
// preview pane
JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPane.add(previewContainerPane, BorderLayout.CENTER);
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));
// init image file chooser.
imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false);
return centerPane;
}
public JPanel initSelectFilePane() {
JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane();
selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY));
defaultRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_DEFAULT"));
customRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-Widget-Style_Custom"));
ButtonGroup buttonGroup = new ButtonGroup();
defaultRadioButton.setSelected(true);
buttonGroup.add(defaultRadioButton);
buttonGroup.add(customRadioButton);
defaultRadioButton.addActionListener(getLayoutActionListener());
customRadioButton.addActionListener(getLayoutActionListener());
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(defaultRadioButton);
jp.add(customRadioButton);
selectPictureButton = new UIButton(
Inter.getLocText("FR-Designer_Background_Image_Select"));
selectPictureButton.addActionListener(getSelectPictureActionListener());
jp.add(selectPictureButton);
selectFilePane.add(jp, BorderLayout.NORTH);
return selectFilePane;
}
private ActionListener getLayoutActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent evt) {
emptyDataImage = null;
checkCustomImage();
repaintPreviewPane();
}
};
}
/**
* Select picture.
*/
private ActionListener getSelectPictureActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int returnVal = imageFileChooser.showOpenDialog(ChartEmptyDataStylePane.this);
if (returnVal != JFileChooser.CANCEL_OPTION) {
final File selectedFile = imageFileChooser.getSelectedFile();
if (selectedFile != null && selectedFile.isFile()) {
previewPane.showLoading();
if (imageWorker != null && !imageWorker.isDone()) {
imageWorker = null;
}
imageWorker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
emptyDataImage = imageFileChooser.isCheckSelected() ? ImageUtils.defaultImageCompress(selectedFile) : BaseUtils.readImage(selectedFile.getPath());
CoreGraphHelper.waitForImage(emptyDataImage);
repaintPreviewPane();
return null;
}
};
imageWorker.execute();
} else {
previewPane.setImage(null);
}
}
}
};
}
private void checkEmptyDataStyle() {
boolean b = emptyData.getSelectedIndex() == 0;
defaultRadioButton.setEnabled(b);
customRadioButton.setEnabled(b);
selectPictureButton.setEnabled(b);
}
private void checkCustomImage() {
selectPictureButton.setVisible(customRadioButton.isSelected());
}
private void repaintPreviewPane() {
emptyDataImage = customRadioButton.isSelected() ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE;
previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null);
previewPane.repaint();
}
@Override
public String getIconPath() {
return StringUtils.EMPTY;
}
@Override
public String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Chart_Empty_Data");
}
public void populateBean() {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() == true ? 0 : 1);
customRadioButton.setSelected(manager.isCustomEmptyDataStyle());
emptyDataImage = manager.getEmptyDataImage();
checkEmptyDataStyle();
checkCustomImage();
repaintPreviewPane();
}
public void updateBean() {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0);
manager.setCustomEmptyDataStyle(customRadioButton.isSelected());
manager.setEmptyDataImage(emptyDataImage);
// 通知报表整个刷新.
DesignerFrame frame = DesignerContext.getDesignerFrame();
if (frame != null) {
frame.repaint();
}
}
}

6
designer-realize/src/com/fr/start/Designer.java

@ -7,7 +7,6 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.newReport.NewPolyReportAction;
import com.fr.design.actions.file.newReport.NewWorkBookAction;
import com.fr.design.actions.file.newReport.NewWorkBookXAction;
import com.fr.design.actions.server.ServerConfigManagerAction;
import com.fr.design.actions.server.StyleListAction;
import com.fr.design.actions.server.WidgetManagerAction;
@ -35,9 +34,7 @@ import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
@ -197,6 +194,9 @@ public class Designer extends BaseDesigner {
if (ActionFactory.getChartPreStyleAction() != null) {
menuDef.addShortCut(ActionFactory.getChartPreStyleAction());
}
if (ActionFactory.getChartEmptyDataStyleAction() != null) {
menuDef.addShortCut(ActionFactory.getChartEmptyDataStyleAction());
}
if (ActionFactory.getChartMapEditorAction() != null) {
menuDef.addShortCut(ActionFactory.getChartMapEditorAction());
}

Loading…
Cancel
Save