|
|
@ -1,7 +1,6 @@ |
|
|
|
package com.fr.design.data.tabledata.tabledatapane; |
|
|
|
package com.fr.design.data.tabledata.tabledatapane; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
|
|
|
import com.fr.base.Parameter; |
|
|
|
import com.fr.base.Parameter; |
|
|
|
import com.fr.base.ParameterHelper; |
|
|
|
import com.fr.base.ParameterHelper; |
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
@ -35,17 +34,25 @@ import com.fr.design.menu.SeparatorDef; |
|
|
|
import com.fr.design.menu.ToolBarDef; |
|
|
|
import com.fr.design.menu.ToolBarDef; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.general.sql.SqlUtils; |
|
|
|
import com.fr.general.sql.SqlUtils; |
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
|
|
|
import javax.swing.Box; |
|
|
|
|
|
|
|
import javax.swing.BoxLayout; |
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import javax.swing.JScrollPane; |
|
|
|
|
|
|
|
import javax.swing.JSplitPane; |
|
|
|
|
|
|
|
import javax.swing.JToolBar; |
|
|
|
import javax.swing.text.BadLocationException; |
|
|
|
import javax.swing.text.BadLocationException; |
|
|
|
import javax.swing.text.Document; |
|
|
|
import javax.swing.text.Document; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
import java.awt.event.FocusListener; |
|
|
|
import java.awt.event.FocusListener; |
|
|
@ -75,7 +82,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
ParameterTableModel model = new ParameterTableModel() { |
|
|
|
ParameterTableModel model = new ParameterTableModel() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public UITableEditAction[] createAction() { |
|
|
|
public UITableEditAction[] createAction() { |
|
|
|
return (UITableEditAction[]) ArrayUtils.add(super.createDBTableAction(), new RefreshAction()); |
|
|
|
return ArrayUtils.add(super.createDBTableAction(), new RefreshAction()); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
editorPane = new UITableEditorPane<ParameterProvider>(model); |
|
|
|
editorPane = new UITableEditorPane<ParameterProvider>(model); |
|
|
@ -84,6 +91,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
connectionTableProcedurePane = new ConnectionTableProcedurePane() { |
|
|
|
connectionTableProcedurePane = new ConnectionTableProcedurePane() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void filter(Connection connection, String conName, List<String> nameList) { |
|
|
|
protected void filter(Connection connection, String conName, List<String> nameList) { |
|
|
|
|
|
|
|
|
|
|
|
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); |
|
|
|
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -95,19 +103,21 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null); |
|
|
|
document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null); |
|
|
|
} catch (BadLocationException e) { |
|
|
|
} catch (BadLocationException e) { |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
// 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的,
|
|
|
|
// 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的,
|
|
|
|
// 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了.
|
|
|
|
// 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了.
|
|
|
|
// sqlTextPane.syntaxTexts();
|
|
|
|
// sqlTextPane.syntaxTexts();
|
|
|
|
sqlTextPane.requestFocus(); |
|
|
|
sqlTextPane.requestFocus(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
sqlTextPane.addFocusListener(new FocusListener() { |
|
|
|
sqlTextPane.addFocusListener(new FocusListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
// unsupport
|
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
if (isPreviewOrRefreshButton(e)) { |
|
|
|
if (isPreviewOrRefreshButton(e)) { |
|
|
|
checkParameter(); |
|
|
|
checkParameter(); |
|
|
@ -146,7 +156,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
sqlSplitPane.add(box, BorderLayout.CENTER); |
|
|
|
sqlSplitPane.add(box, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
box.setMinimumSize(new Dimension(310, 400)); |
|
|
|
box.setMinimumSize(new Dimension(300, 400)); |
|
|
|
|
|
|
|
// 防止数据连接名过长时影响 split pane 分割效果
|
|
|
|
|
|
|
|
connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400)); |
|
|
|
|
|
|
|
connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400)); |
|
|
|
// 使用SplitPane
|
|
|
|
// 使用SplitPane
|
|
|
|
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); |
|
|
|
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); |
|
|
|
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); |
|
|
|
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); |
|
|
@ -160,8 +173,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isPreviewOrRefreshButton(FocusEvent e) { |
|
|
|
private boolean isPreviewOrRefreshButton (FocusEvent e) { |
|
|
|
|
|
|
|
if (e.getOppositeComponent() != null) { |
|
|
|
if (e.getOppositeComponent() != null) { |
|
|
|
String name = e.getOppositeComponent().getName(); |
|
|
|
String name = e.getOppositeComponent().getName(); |
|
|
|
return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); |
|
|
|
return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); |
|
|
@ -272,7 +284,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { |
|
|
|
if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); |
|
|
|
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception ignore) { |
|
|
|
// JOptionPane.showMessageDialog(DBTableDataPane.this,
|
|
|
|
// JOptionPane.showMessageDialog(DBTableDataPane.this,
|
|
|
|
// com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
|
|
|
|
// com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
|
|
|
|
} |
|
|
|
} |
|
|
@ -303,13 +315,14 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
refresh(); |
|
|
|
refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void checkEnabled() { |
|
|
|
public void checkEnabled() { |
|
|
|
// unsupport
|
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -320,6 +333,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
checkParameter(); |
|
|
|
checkParameter(); |
|
|
|
PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); |
|
|
|
PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); |
|
|
@ -333,11 +347,13 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL")); |
|
|
|
final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL")); |
|
|
|
pane.populate(pageQuery); |
|
|
|
pane.populate(pageQuery); |
|
|
|
BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); |
|
|
|
BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); |
|
|
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
pageQuery = pane.update(); |
|
|
|
pageQuery = pane.update(); |
|
|
|
checkParameter(); |
|
|
|
checkParameter(); |
|
|
|