|
|
@ -1,26 +1,32 @@ |
|
|
|
package com.fr.design.data.datapane.connect; |
|
|
|
package com.fr.design.data.datapane.connect; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
|
|
|
import com.fr.base.svg.IconUtils; |
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
|
import com.fr.data.impl.AbstractDatabaseConnection; |
|
|
|
import com.fr.data.impl.AbstractDatabaseConnection; |
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.tabledatapane.loading.SwitchableTableDataPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
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.ilist.TableViewList; |
|
|
|
import com.fr.design.gui.ilist.TableViewList; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.ToolTipManager; |
|
|
|
import javax.swing.ToolTipManager; |
|
|
|
import javax.swing.event.DocumentEvent; |
|
|
|
import javax.swing.event.DocumentEvent; |
|
|
|
import javax.swing.event.DocumentListener; |
|
|
|
import javax.swing.event.DocumentListener; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
@ -45,7 +51,39 @@ public class ConnectionTableProcedurePane extends BasicPane { |
|
|
|
private java.util.List<DoubleClickSelectedNodeOnTreeListener> listeners = new java.util.ArrayList<DoubleClickSelectedNodeOnTreeListener>(); |
|
|
|
private java.util.List<DoubleClickSelectedNodeOnTreeListener> listeners = new java.util.ArrayList<DoubleClickSelectedNodeOnTreeListener>(); |
|
|
|
|
|
|
|
|
|
|
|
public ConnectionTableProcedurePane() { |
|
|
|
public ConnectionTableProcedurePane() { |
|
|
|
|
|
|
|
init(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 传入父容器 |
|
|
|
|
|
|
|
* @param parent |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public ConnectionTableProcedurePane(SwitchableTableDataPane parent) { |
|
|
|
|
|
|
|
init(parent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void init(SwitchableTableDataPane parent) { |
|
|
|
this.setLayout(new BorderLayout(4, 4)); |
|
|
|
this.setLayout(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
// 初始化数据连接下拉框
|
|
|
|
|
|
|
|
initConnectionComboBox(parent); |
|
|
|
|
|
|
|
// 初始化中间的面板
|
|
|
|
|
|
|
|
JPanel centerPane = initCenterPane(); |
|
|
|
|
|
|
|
this.add(connectionComboBox, BorderLayout.NORTH); |
|
|
|
|
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
this.setPreferredSize(new Dimension(WIDTH, getPreferredSize().height)); |
|
|
|
|
|
|
|
addKeyMonitor(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel initCenterPane() { |
|
|
|
|
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
|
|
|
// 搜索面板
|
|
|
|
|
|
|
|
centerPane.add(createSearchPane(), BorderLayout.NORTH); |
|
|
|
|
|
|
|
// 数据库表视图面板
|
|
|
|
|
|
|
|
centerPane.add(createTableViewBorderPane(), BorderLayout.CENTER); |
|
|
|
|
|
|
|
return centerPane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initConnectionComboBox(SwitchableTableDataPane parent) { |
|
|
|
connectionComboBox = new ConnectionComboBoxPanel(com.fr.data.impl.Connection.class) { |
|
|
|
connectionComboBox = new ConnectionComboBoxPanel(com.fr.data.impl.Connection.class) { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -60,10 +98,34 @@ public class ConnectionTableProcedurePane extends BasicPane { |
|
|
|
search(true); |
|
|
|
search(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void afterRefreshItems() { |
|
|
|
|
|
|
|
// 刷新完成后,如果未选中(在nameList初始化完成之前可能会出现),则尝试再次设置
|
|
|
|
|
|
|
|
if (isSelectedItemEmpty()) { |
|
|
|
|
|
|
|
setRecentConnection(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 获取数据连接之后,让父容器切换面板
|
|
|
|
|
|
|
|
if (parent != null) { |
|
|
|
|
|
|
|
parent.switchTo(SwitchableTableDataPane.CONTENT_PANE_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void refreshItemsError() { |
|
|
|
|
|
|
|
// 获取数据连接出现错误时,也让父容器从Loading面板切换至内容面板
|
|
|
|
|
|
|
|
if (parent != null) { |
|
|
|
|
|
|
|
parent.switchTo(SwitchableTableDataPane.CONTENT_PANE_NAME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
connectionComboBox.addComboBoxActionListener(filter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel createTableViewBorderPane() { |
|
|
|
tableViewList = new TableViewList(); |
|
|
|
tableViewList = new TableViewList(); |
|
|
|
ToolTipManager.sharedInstance().registerComponent(tableViewList); |
|
|
|
ToolTipManager.sharedInstance().registerComponent(tableViewList); |
|
|
|
connectionComboBox.addComboBoxActionListener(filter); |
|
|
|
|
|
|
|
tableViewList.addMouseListener(new MouseAdapter() { |
|
|
|
tableViewList.addMouseListener(new MouseAdapter() { |
|
|
|
public void mouseClicked(MouseEvent evt) { |
|
|
|
public void mouseClicked(MouseEvent evt) { |
|
|
|
if (evt.getClickCount() >= 2) { |
|
|
|
if (evt.getClickCount() >= 2) { |
|
|
@ -80,23 +142,50 @@ public class ConnectionTableProcedurePane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
JPanel filterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
UIScrollPane tableViewListPane = new UIScrollPane(tableViewList); |
|
|
|
|
|
|
|
tableViewListPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
|
|
|
|
JPanel tableViewBorderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
|
|
|
tableViewBorderPane.add(tableViewListPane, BorderLayout.CENTER); |
|
|
|
JPanel checkBoxgroupPane = createCheckBoxgroupPane(); |
|
|
|
JPanel checkBoxgroupPane = createCheckBoxgroupPane(); |
|
|
|
if (checkBoxgroupPane != null) { |
|
|
|
if (checkBoxgroupPane != null) { |
|
|
|
filterPane.add(createCheckBoxgroupPane(), BorderLayout.NORTH); |
|
|
|
tableViewBorderPane.add(createCheckBoxgroupPane(), BorderLayout.SOUTH); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return tableViewBorderPane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 创建搜索Panel,用于搜索表或视图 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private JPanel createSearchPane() { |
|
|
|
|
|
|
|
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
JPanel searchPane = new JPanel(new BorderLayout(10, 0)); |
|
|
|
JPanel searchPane = new JPanel(new BorderLayout(10, 0)); |
|
|
|
|
|
|
|
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR)); |
|
|
|
|
|
|
|
searchPane.setBackground(Color.WHITE); |
|
|
|
searchField = new UITextField(); |
|
|
|
searchField = new UITextField(); |
|
|
|
searchPane.add(searchField, BorderLayout.CENTER); |
|
|
|
searchField.setBorderPainted(false); |
|
|
|
|
|
|
|
searchField.setPlaceholder(Toolkit.i18nText("Fine-Design_Basic_Table_Search")); |
|
|
|
searchField.getDocument().addDocumentListener(searchListener); |
|
|
|
searchField.getDocument().addDocumentListener(searchListener); |
|
|
|
filterPane.add(searchPane, BorderLayout.CENTER); |
|
|
|
searchField.addMouseListener(new MouseAdapter() { |
|
|
|
UIScrollPane tableViewListPane = new UIScrollPane(tableViewList); |
|
|
|
@Override |
|
|
|
tableViewListPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
this.add(connectionComboBox, BorderLayout.NORTH); |
|
|
|
super.mouseEntered(e); |
|
|
|
this.add(tableViewListPane, BorderLayout.CENTER); |
|
|
|
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.CHECKBOX_HOVER_SELECTED)); |
|
|
|
this.add(filterPane, BorderLayout.SOUTH); |
|
|
|
} |
|
|
|
this.setPreferredSize(new Dimension(WIDTH, getPreferredSize().height)); |
|
|
|
|
|
|
|
addKeyMonitor(); |
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
|
|
|
super.mouseExited(e); |
|
|
|
|
|
|
|
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 搜索图标
|
|
|
|
|
|
|
|
UILabel searchLabel = new UILabel(IconUtils.readIcon("/com/fr/design/images/data/search")); |
|
|
|
|
|
|
|
searchLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); |
|
|
|
|
|
|
|
searchPane.add(searchField, BorderLayout.CENTER); |
|
|
|
|
|
|
|
searchPane.add(searchLabel, BorderLayout.EAST); |
|
|
|
|
|
|
|
panel.add(searchPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
return panel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void filter(Connection connection, String conName, List<String> nameList) { |
|
|
|
protected void filter(Connection connection, String conName, List<String> nameList) { |
|
|
|