⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 executeprocedurepanel.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * ExecuteProcedurePanel.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.executequery.gui;import java.awt.BorderLayout;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.sql.DatabaseMetaData;import java.sql.SQLException;import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JSplitPane;import javax.swing.JTable;import javax.swing.table.AbstractTableModel;import org.executequery.Constants;import org.executequery.EventMediator;import org.executequery.GUIUtilities;import org.executequery.base.DefaultTabViewActionPanel;import org.underworldlabs.swing.actions.ActionUtilities;import org.underworldlabs.swing.DynamicComboBoxModel;import org.executequery.event.ConnectionEvent;import org.executequery.event.ConnectionListener;import org.executequery.databasemediators.DatabaseConnection;import org.executequery.databasemediators.DatabaseProcedure;import org.executequery.databasemediators.DatabaseResourceHolder;import org.executequery.databasemediators.MetaDataValues;import org.executequery.databasemediators.ProcedureParameter;import org.executequery.databasemediators.QuerySender;import org.executequery.databasemediators.SqlStatementResult;import org.executequery.datasource.ConnectionManager;import org.executequery.gui.editor.QueryEditorResultsPanel;import org.underworldlabs.jdbc.DataSourceException;import org.underworldlabs.swing.FlatSplitPane;import org.underworldlabs.swing.GUIUtils;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.8 $ * @date     $Date: 2006/07/15 13:14:12 $ */public class ExecuteProcedurePanel extends DefaultTabViewActionPanel                                   implements MultiplePanelInstance,                                              ItemListener,                                              ConnectionListener,                                              DatabaseResourceHolder {        public static final String TITLE = "Execute Stored Objects ";    public static final String FRAME_ICON = "Procedure16.gif";        /** the active connections combo box model */    private DynamicComboBoxModel connectionsModel;    /** the schemas combo box model */    private DynamicComboBoxModel schemaModel;    /** the active connections combo */    private JComboBox connectionsCombo;    /** lists available schemas */    private JComboBox schemaCombo;        /** the object type combo */    private JComboBox objectTypeCombo;        /** lists available procedures */    private JComboBox procedureCombo;        /** the active connections combo box model */    private DynamicComboBoxModel proceduresModel;    /** the parameters table */    private JTable table;        /** proc parameters table model */    private ParameterTableModel tableModel;        /** the results panel */    private QueryEditorResultsPanel resultsPanel;        /** database meta data utility */    private MetaDataValues metaData;        /** execution utility */    private QuerySender querySender;        private String[] PROCEDURE;    private String[] FUNCTION;        private boolean useCatalogs;        /** the instance count */    private static int count = 1;        public ExecuteProcedurePanel() {        super(new BorderLayout());                try {            init();        } catch (Exception e) {            e.printStackTrace();        }            }        private void init() throws Exception {        tableModel = new ParameterTableModel();        table = new DefaultTable(tableModel);        table.setRowHeight(20);        table.getTableHeader().setReorderingAllowed(false);        table.setCellSelectionEnabled(true);        table.setColumnSelectionAllowed(false);        table.setRowSelectionAllowed(false);                metaData = new MetaDataValues(true);                // combo boxes        Vector connections = ConnectionManager.getActiveConnections();        connectionsModel = new DynamicComboBoxModel(connections);        connectionsCombo = new JComboBox(connectionsModel);        connectionsCombo.addItemListener(this);        schemaModel = new DynamicComboBoxModel();        schemaCombo = new JComboBox(schemaModel);        schemaCombo.addItemListener(this);        schemaCombo.setToolTipText("Select the schema");                objectTypeCombo = new JComboBox(new String[]{"Functions", "Procedures"});        objectTypeCombo.setToolTipText("Select the database object type");        objectTypeCombo.addItemListener(this);                proceduresModel = new DynamicComboBoxModel();        procedureCombo = new JComboBox(proceduresModel);        procedureCombo.setActionCommand("procedureSelectionChanged");        procedureCombo.setToolTipText("Select the database object name");        procedureCombo.addActionListener(this);                JPanel base = new JPanel(new GridBagLayout());        GridBagConstraints gbc = new GridBagConstraints();        gbc.insets = new Insets(5,7,5,8);        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.BOTH;        gbc.gridy++;        base.add(new JLabel("Connection:"), gbc);        gbc.gridx = 1;        gbc.weightx = 1.0;        gbc.insets.left = 0;                base.add(connectionsCombo, gbc);        gbc.gridx = 0;        gbc.weightx = 0;        gbc.gridy++;        gbc.insets.left = 7;        gbc.insets.top = 0;        base.add(new JLabel("Schema:"), gbc);        gbc.gridx = 1;        gbc.weightx = 1.0;        gbc.insets.left = 0;        base.add(schemaCombo, gbc);        gbc.gridx = 0;        gbc.weightx = 0;        gbc.gridy++;        gbc.insets.left = 7;        gbc.insets.top = 0;        base.add(new JLabel("Object Type:"), gbc);        gbc.gridx = 1;        gbc.weightx = 1.0;        gbc.insets.left = 0;        base.add(objectTypeCombo, gbc);        gbc.gridx = 0;        gbc.weightx = 0;        gbc.gridy++;        gbc.insets.left = 7;        base.add(new JLabel("Object Name:"), gbc);        gbc.gridx = 1;        gbc.weightx = 1.0;        gbc.insets.left = 0;        base.add(procedureCombo, gbc);                resultsPanel = new QueryEditorResultsPanel();        JPanel resultsBase = new JPanel(new BorderLayout());        resultsBase.add(resultsPanel, BorderLayout.CENTER);                JSplitPane splitPane = null;        if (GUIUtilities.getLookAndFeel() < Constants.GTK_LAF) {            splitPane = new FlatSplitPane(JSplitPane.VERTICAL_SPLIT,                                          new JScrollPane(table),                                          resultsBase);        }        else {            splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,                                       new JScrollPane(table),                                       resultsBase);        }        splitPane.setResizeWeight(0.5);        splitPane.setDividerLocation(0.75);        splitPane.setDividerSize(5);                gbc.gridy++;        gbc.gridx = 0;        gbc.weighty = 1.0;        gbc.insets.left = 7;        gbc.gridwidth = GridBagConstraints.REMAINDER;        base.add(splitPane, gbc);                JButton executeButton = ActionUtilities.createButton(this, "Execute", "execute");        executeButton.setPreferredSize(Constants.FORM_BUTTON_SIZE);        executeButton.setMinimumSize(Constants.FORM_BUTTON_SIZE);        gbc.gridy++;        gbc.weighty = 0;        gbc.fill = GridBagConstraints.NONE;        gbc.anchor = GridBagConstraints.EAST;        base.add(executeButton, gbc);                base.setBorder(BorderFactory.createEtchedBorder());        setBorder(BorderFactory.createEmptyBorder(5,5,7,5));                add(base, BorderLayout.CENTER);                PROCEDURE = new String[]{"PROCEDURE"};        FUNCTION = new String[]{"FUNCTION"};                // check initial values for possible value inits        if (connections == null || connections.isEmpty()) {            enableCombos(false);        } else {            DatabaseConnection connection =                     (DatabaseConnection)connections.elementAt(0);            metaData.setDatabaseConnection(connection);            Vector schemas = metaData.getHostedSchemasVector();            if (schemas == null || schemas.isEmpty()) {                useCatalogs = true;                schemas = metaData.getHostedCatalogsVector();            }            schemaModel.setElements(schemas);            schemaCombo.setSelectedIndex(0);        }        EventMediator.registerListener(EventMediator.CONNECTION_EVENT, this);    }    private void enableCombos(boolean enable) {        schemaCombo.setEnabled(enable);        connectionsCombo.setEnabled(enable);        schemaCombo.setEnabled(enable);                if (objectTypeCombo.isEnabled()) {            objectTypeCombo.setEnabled(enable);        }        procedureCombo.setEnabled(enable);    }        /**     * Invoked when an item has been selected or deselected by the user.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -