Browse Source

Merge pull request #3965 in DESIGN/design from feature/10.0 to feature/x

* commit '0468ffc971f9978dc19e19a3928d7bfbfab93e63':
  CHART-18846 && CHART-18865 仪表盘面板修改
  CHART-18859 文件获取路径修改
  REPORT-49023   根据pr来修改代码
  REPORT-49023   数据连接界面报错优化
research/11.0
superman 4 years ago
parent
commit
5419c6b26e
  1. 313
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  2. 8
      designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java
  3. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Down_16x16.png
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png
  5. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png
  6. 14
      designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java
  7. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java
  8. 1
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java

313
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -7,6 +7,10 @@ import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.operator.DataOperator;
import com.fr.data.solution.ExceptionSolutionSelector;
import com.fr.data.solution.entity.DriverPage;
import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor;
import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
@ -15,7 +19,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
@ -25,19 +28,28 @@ import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.HashMap;
import java.util.Map;
import java.net.URI;
import java.util.concurrent.ExecutionException;
/**
@ -50,6 +62,11 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private UIButton cancelButton;
private JDialog dialog;
private UILabel uiLabel;
private UILabel directUiLabel;
private UILabel detailLabel;
private JPanel midPane;
private JPanel hiddenPanel;
// 编码转换.
private UIComboBox charSetComboBox;
private String originalCharSet = null;
@ -59,36 +76,168 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
this.initComponents();
}
protected void initComponents() {
message = new UILabel();
uiLabel = new UILabel();
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
String[] defaultEncode = new String[] {Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH);
ActionListener testConnectionActionListener = new ActionListener() {
private boolean firstCreate = true;
// 按钮.
JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
northPane.add(testPane, BorderLayout.NORTH);
UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"));
testPane.add(testButton);
testButton.addActionListener(testConnectionActionListener);
testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4));
@Override
public void actionPerformed(ActionEvent evt) {
// Center
northPane.add(mainPanel(), BorderLayout.CENTER);
// ChartSet
JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
northPane.add(chartSetPane);
chartSetPane.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP),
Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
}
// Try the java connection.
final SwingWorker<Void, Void> connectionThread = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
Connection database = DatabaseConnectionPane.this.updateBean();
// 返回连接结果
DriverPage.updateCache();
DataOperator.getInstance().testConnectionWithException(database);
return null;
}
@Override
protected void done() {
try {
get();
dialog.setSize(new Dimension(380, 118));
okButton.setEnabled(true);
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully"));
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (ExecutionException e) {
dialog.setSize(new Dimension(380, 142));
midPane.setVisible(true);
hiddenPanel.setVisible(false);
okButton.setEnabled(true);
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed"));
SolutionProcessor select = ExceptionSolutionSelector.get().select(e);
if (select instanceof ClassNotFoundExceptionSolutionProcessor) {
JPanel gridJpanel = new JPanel();
gridJpanel.setLayout(new GridLayout(5, 1, 0, 5));
UILabel driverTips = new UILabel();
driverTips.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver"));
gridJpanel.add(driverTips);
UILabel deatail = new UILabel();
String content = Toolkit.i18nText("Fine_Designer_Not_Found") + select.getResultException().getDetailMessage() + Toolkit.i18nText("Fine_Designer_Driver");
deatail.setText(content);
deatail.setToolTipText(content);
gridJpanel.add(deatail);
String solution = select.getResultException().getSolution();
UILabel redirect = new UILabel();
if (solution != null) {
redirect.setText(Toolkit.i18nText("Fine_Designer_Download_Driver"));
redirect.setForeground(Color.BLUE);
redirect.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI(solution));
} catch (Exception clickException) {
FineLoggerFactory.getLogger().warn("can not open browser with {}", solution);
}
}
@Override
public void mouseEntered(MouseEvent e) {
redirect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseExited(MouseEvent e) {
redirect.setCursor(Cursor.getDefaultCursor());
}
});
} else {
redirect.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver_No_Solution"));
}
gridJpanel.add(redirect);
hiddenPanel.add(gridJpanel);
gridJpanel.setBackground(Color.WHITE);
} else {
JPanel borderPanel = new JPanel();
borderPanel.setLayout(new BorderLayout());
JTextArea jta = new JTextArea();
JScrollPane jsp = new JScrollPane(jta);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jta.append(select.getResultException().getDetailMessage() + "\n");
jta.append(select.getResultException().getSolution());
jta.setCaretPosition(0);
jta.setEditable(false);
jta.getCaret().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
jta.getCaret().setVisible(true);
}
});
borderPanel.add(jsp, BorderLayout.CENTER);
hiddenPanel.add(borderPanel);
}
okButton.setEnabled(true);
}
}
};
midPane.setVisible(false);
hiddenPanel.setVisible(false);
initDialogPane();
connectionThread.execute();
// 老bug,initDialogPane 中的 dialog每次都是new的,所以可以重新添加 listener,但是其他的对象不行,会多次添加listener
if (firstCreate) {
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hiddenPanel.removeAll();
dialog.dispose();
}
});
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hiddenPanel.removeAll();
dialog.dispose();
connectionThread.cancel(true);
}
});
detailLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (hiddenPanel.isVisible()) {
hiddenPanel.setVisible(false);
dialog.setSize(new Dimension(380, 142));
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
} else {
dialog.setSize(new Dimension(380, 260));
hiddenPanel.setVisible(true);
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
}
}
@Override
public void mouseEntered(MouseEvent e) {
detailLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseExited(MouseEvent e) {
detailLabel.setCursor(Cursor.getDefaultCursor());
}
});
firstCreate = false;
}
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
connectionThread.cancel(true);
}
});
dialog.setVisible(true);
hiddenPanel.removeAll();
dialog.dispose();
}
};
protected abstract JPanel mainPanel();
@ -127,83 +276,72 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
protected abstract E updateSubDatabaseConnectionBean();
ActionListener testConnectionActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// Try the java connection.
final SwingWorker<Boolean, Void> connectionThread = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
Connection database = DatabaseConnectionPane.this.updateBean();
// 返回连接结果
return DataOperator.getInstance().testConnection(database);
}
@Override
protected void done() {
try {
boolean connect = get();
okButton.setEnabled(true);
if (connect) {
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully"));
}else{
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed"));
}
} catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
};
connectionThread.execute();
initDialogPane();
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
connectionThread.cancel(true);
}
});
protected void initComponents() {
message = new UILabel();
uiLabel = new UILabel();
detailLabel = new UILabel();
directUiLabel = new UILabel();
hiddenPanel = new JPanel();
midPane = new JPanel();
midPane.add(directUiLabel);
midPane.add(detailLabel);
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH);
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
connectionThread.cancel(true);
}
});
// 按钮.
JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
northPane.add(testPane, BorderLayout.NORTH);
UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"));
testPane.add(testButton);
testButton.addActionListener(testConnectionActionListener);
testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4));
dialog.setVisible(true);
dialog.dispose();
}
};
// Center
northPane.add(mainPanel(), BorderLayout.CENTER);
// ChartSet
JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
northPane.add(chartSetPane);
chartSetPane.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP),
Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
}
private void initDialogPane() {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection") + "...");
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(DatabaseConnectionPane.this), Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"), true);
dialog.setSize(new Dimension(268, 118));
dialog.setSize(new Dimension(380, 118));
okButton.setEnabled(false);
JPanel jp = new JPanel();
JPanel upPane = new JPanel();
JPanel downPane = new JPanel();
uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel);
upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
midPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
detailLabel.setForeground(Color.BLUE);
hiddenPanel.setLayout(new BorderLayout(10, 0));
hiddenPanel.add(new JPanel(), BorderLayout.WEST);
hiddenPanel.add(new JPanel(), BorderLayout.EAST);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 9));
downPane.add(okButton);
downPane.add(cancelButton);
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(upPane);
jp.add(midPane);
jp.add(hiddenPanel);
jp.add(downPane);
dialog.add(jp);
dialog.setResizable(false);
@ -268,5 +406,4 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
return "JNDI";
}
}
}

8
designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java

@ -30,10 +30,12 @@ import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI;
import com.fr.design.gui.itooltip.UIToolTipBorder;
import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.BorderUIResource;
@ -171,6 +173,8 @@ public class UILookAndFeel extends MetalLookAndFeel {
table.put("FileChooser.upFolderIcon", loadIcon("ParentDirectoryIcon.png", this));
table.put("OptionPane.errorIcon", loadIcon("Information_Icon_Error_32x32.png", this));
table.put("OptionPane.informationIcon", loadIcon("Information_Icon_OK_32x32.png", this));
table.put("OptionPane.narrow.right", loadIcon("icon_narrow_right_16x16.png", this));
table.put("OptionPane.narrow.down", loadIcon("icon_narrow_down_16x16.png", this));
table.put("OptionPane.warningIcon", loadIcon("WarningIcon.png", this));
table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this));
table.put("ScrollPane.border", new UIScrollPaneBorder());

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Down_16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 752 B

After

Width:  |  Height:  |  Size: 760 B

14
designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

@ -23,6 +23,9 @@ import org.apache.batik.swing.svg.SVGFileFilter;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
@ -30,9 +33,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* 自定义地图界面.
@ -117,7 +117,11 @@ refreshAreaNameBox();
int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (returnVal != JFileChooser.CANCEL_OPTION) {
File selectedFile = svgFileChooser.getSelectedFile();
lastSelectPath = selectedFile.getAbsolutePath();
try {
lastSelectPath = selectedFile.getCanonicalPath();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (selectedFile != null && selectedFile.isFile()) {
imageShowPane.setSvgMap(selectedFile.getPath());
imageShowPane.repaint();
@ -133,7 +137,7 @@ refreshAreaNameBox();
String colName = Utils.objectToString(areaString.getSelectedItem());
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName));
}
}

7
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java

@ -23,7 +23,12 @@ public class RefreshTooltipContentPaneWithOutSeries extends TooltipContentPaneWi
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) {
super.initFormatPane(parent, showOnPane);
setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane));
setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane) {
@Override
protected String getCheckBoxText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Change_Value");
}
});
setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane));
}

1
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java

@ -134,6 +134,7 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane
protected AttrTooltipContent createAttrTooltip() {
GaugeValueTooltipContent gaugeValueTooltipContent = new GaugeValueTooltipContent();
gaugeValueTooltipContent.setCustom(false);
gaugeValueTooltipContent.getTargetValueFormat().setEnable(true);
gaugeValueTooltipContent.getRichTextTargetValueFormat().setEnable(true);
return gaugeValueTooltipContent;

Loading…
Cancel
Save