From bf587d0af4d2b454b58f3be7f4c46abd02de87fa Mon Sep 17 00:00:00 2001 From: xiqiu Date: Fri, 9 Apr 2021 14:49:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-49023=20=20=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E7=95=8C=E9=9D=A2=E6=8A=A5=E9=94=99=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connect/DatabaseConnectionPane.java | 307 +++++++++++++----- .../java/com/fr/design/gui/UILookAndFeel.java | 8 +- .../lookandfeel/Icon_Narrow_Down_16x16.png | Bin 0 -> 162 bytes .../lookandfeel/Icon_Narrow_Right_16x16.png | Bin 0 -> 153 bytes .../Information_Icon_Error_32x32.png | Bin 752 -> 760 bytes 5 files changed, 225 insertions(+), 90 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Down_16x16.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index f6bfdd29a7..436849936e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -7,6 +7,9 @@ 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.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 +18,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 +27,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 +61,11 @@ public abstract class DatabaseConnectionPane connectionThread = new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + Connection database = DatabaseConnectionPane.this.updateBean(); + // 返回连接结果 + 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); + UILabel redirect = new UILabel(); + 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(select.getResultException().getSolution())); + } catch (Exception clickException) { + FineLoggerFactory.getLogger().warn("can not open browser with {}", select.getResultException().getSolution()); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + redirect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + redirect.setCursor(Cursor.getDefaultCursor()); + } + }); + 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 +270,72 @@ public abstract class DatabaseConnectionPane connectionThread = new SwingWorker() { - @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 +400,4 @@ public abstract class DatabaseConnectionPanez8=w2-`T z-(It&u`$tfVxmw~#Ek81OT<)pe*IRzZfx);|3E%RvU6f$p0W?Go5CY=mQdq1?u2DY z<}AU+e#{O+E7}sS_grUaQRLw{QRl`#|KXGg9X<{cr!@GO8P4k}3a0T^=K(Ec@O1Ta JS?83{1OTdcG0Xq} literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png b/designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..a1ac42cfea737bcdea8089102f4c1157e8b2b5c6 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`37#&FAr}70DGLM)f>z9DT+R6R z?_?(~?$6f*k}dR@{}~$?n2CrzGZQjm>1R|}+rq1uz>w(NVZg9o(M77^wm_9+gSA0t z0pq_J3sOyl{FomsI6Cc;hTo}{N&1^?j_wp>IHF}G82u_W5@;8Lr>mdKI;Vst0CD0k AO#lD@ literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png b/designer-base/src/main/resources/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png index 8c8831e6dd9a5bc0c3be913f2392ef6ab16e667b..b5df7646ed1833a5c5fb1dfe94e402021c5b5718 100644 GIT binary patch delta 691 zcmV;k0!;nz1^5M!BoPE>K}|sb0I`n?{9y$E00OU(GBJN@^rRPW_#@oZgZc*mjW?=> zR9l1?BtpAO$N46i?R0lrx3h_O;7gjBdGp@)-oAPBri=t$zx~KD{wvH}I>(f+gqrNv zco4ur1}qfc_=&OoszLfck6^FSpmJqBc2>Xvu1*MKz;*Yi{C%BvcWa&OBJF_#T;Obn zKmgT^O>%!6$J1Z^vPSp;-OgbHE^xMkY>A&%zk010(SED`kcM%K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!IjZ%NmF%VojvJ)7z1)#}<0cppZD-r&hIPl|}7_|kU z!!?8Zn^z`o1Zu+Z;jDAOK#Wz=-CgJUi^U!74B%oxZ}&iuHw%tE(vIK)LT4Vq@{){TgtyU>@Q3fcrZB4f6sLB#)t{ Rwj}@n002ovPDHLkV1j1eQBD8= From 4ddd6b5efef03e30ee14a6e05c31efbb7fdf4719 Mon Sep 17 00:00:00 2001 From: xiqiu Date: Mon, 12 Apr 2021 18:06:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-49023=20=20=20=E6=A0=B9=E6=8D=AEpr?= =?UTF-8?q?=E6=9D=A5=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connect/DatabaseConnectionPane.java | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 436849936e..16c992b0f3 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -8,6 +8,7 @@ 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; @@ -87,6 +88,7 @@ public abstract class DatabaseConnectionPane