0001: package org.jsqltool.gui;
0002:
0003: import java.awt.*;
0004: import java.awt.event.*;
0005: import javax.swing.*;
0006: import javax.swing.event.*;
0007: import org.jsqltool.conn.*;
0008: import org.jsqltool.*;
0009: import java.beans.*;
0010: import org.jsqltool.conn.gui.*;
0011: import org.jsqltool.replication.gui.*;
0012: import java.util.*;
0013: import java.sql.*;
0014: import java.io.*;
0015: import org.jsqltool.utils.Options;
0016: import org.jsqltool.utils.ImageLoader;
0017: import java.lang.reflect.*;
0018:
0019: /**
0020: * <p>Title: JSqlTool Project</p>
0021: * <p>Description: This is the main frame.
0022: * </p>
0023: * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
0024: *
0025: * <p> This file is part of JSqlTool project.
0026: * This library is free software; you can redistribute it and/or
0027: * modify it under the terms of the (LGPL) Lesser General Public
0028: * License as published by the Free Software Foundation;
0029: *
0030: * GNU LESSER GENERAL PUBLIC LICENSE
0031: * Version 2.1, February 1999
0032: *
0033: * This library is distributed in the hope that it will be useful,
0034: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0035: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0036: * Library General Public License for more details.
0037: *
0038: * You should have received a copy of the GNU Library General Public
0039: * License along with this library; if not, write to the Free
0040: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0041: *
0042: * The author may be contacted at:
0043: * maurocarniel@tin.it</p>
0044: *
0045: * @author Mauro Carniel
0046: * @version 1.0
0047: */
0048: public class MainFrame extends JFrame {
0049:
0050: JPanel contentPane;
0051: JMenuBar menuBar = new JMenuBar();
0052: JMenu menuFile = new JMenu();
0053: JMenuItem menuFileExit = new JMenuItem();
0054: JMenu menuHelp = new JMenu();
0055: JMenuItem menuHelpAbout = new JMenuItem();
0056: JToolBar toolbar = new JToolBar();
0057: JButton queryButton = new JButton();
0058: JButton listaButton = new JButton();
0059: JButton schemaButton = new JButton();
0060: JButton commitButton = new JButton();
0061: JButton rollbackButton = new JButton();
0062: ImageIcon queryImage;
0063: ImageIcon listaImage;
0064: ImageIcon schemaImage;
0065: ImageIcon commitImage;
0066: ImageIcon rollbackImage;
0067: JPanel statusBar = new JPanel();
0068: BorderLayout borderLayout1 = new BorderLayout();
0069: JMenuItem menuFileNewConn = new JMenuItem();
0070: JDesktopPane desktop = new JDesktopPane();
0071: JMenuItem menuFileEndItem = new JMenuItem();
0072: JMenuItem menuFileEndAllItem = new JMenuItem();
0073: ConnWindows connWindowManager = new ConnWindows(this , desktop,
0074: statusBar);
0075: JMenu viewMenu = new JMenu();
0076: JMenu sqlMenu = new JMenu();
0077: JMenu dbMenu = new JMenu();
0078: JMenu winMenu = new JMenu();
0079: JMenuItem currSqlMenuItem = new JMenuItem();
0080: JMenuItem recallListMenuItem = new JMenuItem();
0081: JMenuItem explainPlanMenuItem = new JMenuItem();
0082: JMenuItem importSQLMenuItem = new JMenuItem();
0083: JMenuItem schemaBrowserMenuItem = new JMenuItem();
0084: JMenuItem dbSchemaMenuItem = new JMenuItem();
0085: JMenuItem sqlEditorMenuItem = new JMenuItem();
0086: JMenuItem commitMenuItem = new JMenuItem();
0087: JMenuItem rollbackMenuItem = new JMenuItem();
0088: JMenuItem optionsMenuItem = new JMenuItem();
0089: JMenuItem closeAllMenuItem = new JMenuItem();
0090: JMenuItem traceMenuItem = new JMenuItem();
0091: JMenuItem menuFileRep = new JMenuItem();
0092: FlowLayout flowLayout1 = new FlowLayout();
0093:
0094: /** instance of the class */
0095: private static MainFrame instance = null;
0096:
0097: /**
0098: * Construct the frame.
0099: */
0100: public MainFrame() {
0101: instance = this ;
0102: enableEvents(AWTEvent.WINDOW_EVENT_MASK);
0103: this .setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
0104: Dimension screenSize = Toolkit.getDefaultToolkit()
0105: .getScreenSize();
0106: this .setSize((int) screenSize.getWidth(), (int) screenSize
0107: .getHeight() - 24);
0108: // this.setSize(screenSize);
0109: JFrame.setDefaultLookAndFeelDecorated(true);
0110: GraphicsEnvironment env = GraphicsEnvironment
0111: .getLocalGraphicsEnvironment();
0112: this .setExtendedState(this .getExtendedState()
0113: | this .MAXIMIZED_BOTH);
0114:
0115: try {
0116: init();
0117: jbInit();
0118: desktop.setBackground(menuBar.getBackground());
0119: menuFileNewConn_actionPerformed(null);
0120: } catch (Exception e) {
0121: e.printStackTrace();
0122: }
0123: }
0124:
0125: /**
0126: * @return instance of the class
0127: */
0128: public static MainFrame getInstance() {
0129: return instance;
0130: }
0131:
0132: /**
0133: * Load from file system the application profile file (profile/jsqltool.ini).
0134: * If profile file doesn't exists, then create a new one.
0135: */
0136: private void init() {
0137: try {
0138: Properties p = new Properties();
0139: File profileFile = new File("jsqltool.ini");
0140: if (!profileFile.exists()) {
0141: p.setProperty("DATE_FORMAT", "dd-MM-yyyy hh:mm:ss");
0142: p.setProperty("ORACLE_EXPLAIN_PLAN_TABLE",
0143: "TOAD_PLAN_TABLE");
0144: p.setProperty("UPDATE_WHEN_NO_PK", "true");
0145: p.setProperty("LANGUAGE", Locale.getDefault()
0146: .getLanguage());
0147: p.save(new FileOutputStream(profileFile),
0148: "JSQLTOOL Properties");
0149: } else
0150: p.load(new FileInputStream(profileFile));
0151:
0152: // set onto Options singleton the values retrieved from profile.
0153: Options.getInstance()
0154: .setDateFormat(
0155: p.getProperty("DATE_FORMAT",
0156: "dd-MM-yyyy hh:mm:ss"));
0157: Options.getInstance().setOracleExplainPlanTable(
0158: p.getProperty("ORACLE_EXPLAIN_PLAN_TABLE",
0159: "TOAD_PLAN_TABLE"));
0160: Options.getInstance().setUpdateWhenNoPK(
0161: p.getProperty("UPDATE_WHEN_NO_PK", "true").equals(
0162: "true"));
0163: Options.getInstance().setLanguage(
0164: p.getProperty("LANGUAGE", Locale.getDefault()
0165: .getLanguage()));
0166:
0167: } catch (Exception ex) {
0168: ex.printStackTrace();
0169: JOptionPane.showMessageDialog(this , Options.getInstance()
0170: .getResource("error while loading jsqltool.ini")
0171: + ":\n" + ex.getMessage(), Options.getInstance()
0172: .getResource("error"), JOptionPane.ERROR_MESSAGE);
0173: }
0174: }
0175:
0176: /**
0177: * Initialize graphics components.
0178: */
0179: private void jbInit() throws Exception {
0180: try {
0181: queryImage = ImageLoader.getInstance().getIcon("query.gif");
0182: listaImage = ImageLoader.getInstance()
0183: .getIcon("tables.gif");
0184: schemaImage = ImageLoader.getInstance().getIcon(
0185: "schema.gif");
0186: commitImage = ImageLoader.getInstance().getIcon(
0187: "commit.gif");
0188: rollbackImage = ImageLoader.getInstance().getIcon(
0189: "rollback.gif");
0190: setIconImage(ImageLoader.getInstance().getIcon("logo.gif")
0191: .getImage());
0192: } catch (Exception ex) {
0193: ex.printStackTrace();
0194: JOptionPane.showMessageDialog(this , Options.getInstance()
0195: .getResource("image files not found."), Options
0196: .getInstance().getResource("error"),
0197: JOptionPane.ERROR_MESSAGE);
0198: System.exit(1);
0199: }
0200: contentPane = (JPanel) this .getContentPane();
0201: contentPane.setLayout(borderLayout1);
0202: this .setTitle("JSqlTool");
0203: menuFile.setMnemonic(Options.getInstance().getResource(
0204: "file.mnemonic").charAt(0));
0205: menuFile
0206: .setText(Options.getInstance().getResource("file.text"));
0207: menuFileExit.setMnemonic(Options.getInstance().getResource(
0208: "exit.mnemonic").charAt(0));
0209: menuFileExit.setText(Options.getInstance().getResource(
0210: "exit.text"));
0211: menuFileExit
0212: .addActionListener(new MainFrame_menuFileExit_ActionAdapter(
0213: this ));
0214: menuFileRep.setMnemonic(Options.getInstance().getResource(
0215: "exit.mnemonic").charAt(0));
0216: menuFileRep.setText(Options.getInstance().getResource(
0217: "data replication.text"));
0218: menuFileRep
0219: .addActionListener(new MainFrame_menuFileRep_ActionAdapter(
0220: this ));
0221:
0222: menuHelp.setMnemonic(Options.getInstance().getResource(
0223: "help.mnemonic").charAt(0));
0224: menuHelp
0225: .setText(Options.getInstance().getResource("help.text"));
0226: menuHelpAbout.setMnemonic(Options.getInstance().getResource(
0227: "about.mnemonic").charAt(0));
0228: menuHelpAbout.setText(Options.getInstance().getResource(
0229: "about.text"));
0230: menuHelpAbout
0231: .addActionListener(new MainFrame_menuHelpAbout_ActionAdapter(
0232: this ));
0233: queryButton.setIcon(queryImage);
0234: queryButton
0235: .addActionListener(new MainFrame_queryButton_actionAdapter(
0236: this ));
0237: queryButton.setToolTipText(Options.getInstance().getResource(
0238: "querybutton.tooltip"));
0239: queryButton.setBorder(null);
0240: queryButton.setMaximumSize(new Dimension(24, 24));
0241: queryButton.setPreferredSize(new Dimension(24, 24));
0242: listaButton.setBorder(null);
0243: listaButton.setMaximumSize(new Dimension(24, 24));
0244: listaButton.setPreferredSize(new Dimension(24, 24));
0245: schemaButton.setBorder(null);
0246: schemaButton.setMaximumSize(new Dimension(24, 24));
0247: schemaButton.setPreferredSize(new Dimension(24, 24));
0248: commitButton.setBorder(null);
0249: commitButton.setMaximumSize(new Dimension(24, 24));
0250: commitButton.setPreferredSize(new Dimension(24, 24));
0251: rollbackButton.setBorder(null);
0252: rollbackButton.setMaximumSize(new Dimension(24, 24));
0253: rollbackButton.setPreferredSize(new Dimension(24, 24));
0254: listaButton.setIcon(listaImage);
0255: listaButton
0256: .addActionListener(new MainFrame_listaButton_actionAdapter(
0257: this ));
0258: listaButton.setToolTipText(Options.getInstance().getResource(
0259: "listabutton.tooltip"));
0260: schemaButton.setIcon(schemaImage);
0261: schemaButton
0262: .addActionListener(new MainFrame_schemaButton_actionAdapter(
0263: this ));
0264: schemaButton.setToolTipText(Options.getInstance().getResource(
0265: "schemabutton.tooltip"));
0266: commitButton.setIcon(commitImage);
0267: commitButton
0268: .addActionListener(new MainFrame_commitButton_actionAdapter(
0269: this ));
0270: commitButton.setToolTipText(Options.getInstance().getResource(
0271: "commitbutton.tooltip"));
0272: rollbackButton.setIcon(rollbackImage);
0273: rollbackButton
0274: .addActionListener(new MainFrame_rollbackButton_actionAdapter(
0275: this ));
0276: rollbackButton.setToolTipText(Options.getInstance()
0277: .getResource("rollbackbutton.tooltip"));
0278: menuFileNewConn.setMnemonic(Options.getInstance().getResource(
0279: "newconn.mnemonic").charAt(0));
0280: menuFileNewConn.setText(Options.getInstance().getResource(
0281: "newconn.text"));
0282: menuFileNewConn
0283: .addActionListener(new MainFrame_menuFileNewConn_actionAdapter(
0284: this ));
0285: menuFileEndItem.setMnemonic(Options.getInstance().getResource(
0286: "endconn.mnemonic").charAt(0));
0287: menuFileEndItem.setText(Options.getInstance().getResource(
0288: "endconn.text"));
0289: menuFileEndItem
0290: .addActionListener(new MainFrame_menuFileEndItem_actionAdapter(
0291: this ));
0292: menuFileEndAllItem.setMnemonic(Options.getInstance()
0293: .getResource("endallconn.mnemonic").charAt(0));
0294: menuFileEndAllItem.setText(Options.getInstance().getResource(
0295: "endallconn.text"));
0296: menuFileEndAllItem
0297: .addActionListener(new MainFrame_menuFileEndAllItem_actionAdapter(
0298: this ));
0299: sqlMenu.setMnemonic(Options.getInstance().getResource(
0300: "sqlwindow.mnemonic").charAt(0));
0301: sqlMenu.setText(Options.getInstance().getResource(
0302: "sqlwindow.text"));
0303: dbMenu.setMnemonic(Options.getInstance().getResource(
0304: "database.mnemonic").charAt(0));
0305: dbMenu.setText(Options.getInstance().getResource(
0306: "database.text"));
0307: viewMenu.setMnemonic(Options.getInstance().getResource(
0308: "view.mnemonic").charAt(0));
0309: viewMenu
0310: .setText(Options.getInstance().getResource("view.text"));
0311: winMenu.setMnemonic(Options.getInstance().getResource(
0312: "window.mnemonic").charAt(0));
0313: winMenu.setText(Options.getInstance()
0314: .getResource("window.text"));
0315: currSqlMenuItem.setMnemonic(Options.getInstance().getResource(
0316: "sql.mnemonic").charAt(0));
0317: currSqlMenuItem.setText(Options.getInstance().getResource(
0318: "sql.text"));
0319: currSqlMenuItem.setAccelerator(javax.swing.KeyStroke
0320: .getKeyStroke(KeyEvent.VK_F9,
0321: java.awt.event.KeyEvent.SHIFT_MASK, false));
0322: currSqlMenuItem
0323: .addActionListener(new MainFrame_currSqlMenuItem_actionAdapter(
0324: this ));
0325: recallListMenuItem.setToolTipText("");
0326: recallListMenuItem.setMnemonic(Options.getInstance()
0327: .getResource("oldsqllist.mnemonic").charAt(0));
0328: recallListMenuItem.setText(Options.getInstance().getResource(
0329: "oldsqllist.text"));
0330: recallListMenuItem
0331: .addActionListener(new MainFrame_recallListMenuItem_actionAdapter(
0332: this ));
0333: explainPlanMenuItem.setMnemonic(Options.getInstance()
0334: .getResource("plan.mnemonic").charAt(0));
0335: explainPlanMenuItem.setText(Options.getInstance().getResource(
0336: "plan.text"));
0337: explainPlanMenuItem.setAccelerator(javax.swing.KeyStroke
0338: .getKeyStroke('E', java.awt.event.KeyEvent.CTRL_MASK,
0339: false));
0340: explainPlanMenuItem
0341: .addActionListener(new MainFrame_explainPlanMenuItem_actionAdapter(
0342: this ));
0343:
0344: importSQLMenuItem.setMnemonic(Options.getInstance()
0345: .getResource("importsql.mnemonic").charAt(0));
0346: importSQLMenuItem.setText(Options.getInstance().getResource(
0347: "importsql.text"));
0348: importSQLMenuItem.setAccelerator(javax.swing.KeyStroke
0349: .getKeyStroke('S', java.awt.event.KeyEvent.CTRL_MASK,
0350: false));
0351: importSQLMenuItem
0352: .addActionListener(new MainFrame_importSQLMenuItem_actionAdapter(
0353: this ));
0354:
0355: schemaBrowserMenuItem.setMnemonic(Options.getInstance()
0356: .getResource("schemabrowser.mnemonic").charAt(0));
0357: schemaBrowserMenuItem.setText(Options.getInstance()
0358: .getResource("schemabrowser.text"));
0359: schemaBrowserMenuItem
0360: .addActionListener(new MainFrame_schemaBrowserMenuItem_actionAdapter(
0361: this ));
0362:
0363: dbSchemaMenuItem.setMnemonic(Options.getInstance().getResource(
0364: "dbschema.mnemonic").charAt(0));
0365: dbSchemaMenuItem.setText(Options.getInstance().getResource(
0366: "dbschema.text"));
0367: dbSchemaMenuItem
0368: .addActionListener(new MainFrame_dbSchemaMenuItem_actionAdapter(
0369: this ));
0370:
0371: sqlEditorMenuItem.setMnemonic(Options.getInstance()
0372: .getResource("sqleditor.mnemonic").charAt(0));
0373: sqlEditorMenuItem.setText(Options.getInstance().getResource(
0374: "sqleditor.text"));
0375: sqlEditorMenuItem
0376: .addActionListener(new MainFrame_sqlEditorMenuItem_actionAdapter(
0377: this ));
0378: commitMenuItem.setMnemonic(Options.getInstance().getResource(
0379: "commit.mnemonic").charAt(0));
0380: commitMenuItem.setText(Options.getInstance().getResource(
0381: "commit.text"));
0382: commitMenuItem
0383: .addActionListener(new MainFrame_commitMenuItem_actionAdapter(
0384: this ));
0385: rollbackMenuItem.setMnemonic(Options.getInstance().getResource(
0386: "rollback.mnemonic").charAt(0));
0387: rollbackMenuItem.setText(Options.getInstance().getResource(
0388: "rollback.text"));
0389: rollbackMenuItem
0390: .addActionListener(new MainFrame_rollbackMenuItem_actionAdapter(
0391: this ));
0392: optionsMenuItem.setMnemonic(Options.getInstance().getResource(
0393: "options.mnemonic").charAt(0));
0394: optionsMenuItem.setText(Options.getInstance().getResource(
0395: "options.text"));
0396: optionsMenuItem
0397: .addActionListener(new MainFrame_optionsMenuItem_actionAdapter(
0398: this ));
0399: closeAllMenuItem.setMnemonic(Options.getInstance().getResource(
0400: "closeall.mnemonic").charAt(0));
0401: closeAllMenuItem.setText(Options.getInstance().getResource(
0402: "closeall.text"));
0403: closeAllMenuItem
0404: .addActionListener(new MainFrame_closeAllMenuItem_actionAdapter(
0405: this ));
0406: traceMenuItem.setMnemonic(Options.getInstance().getResource(
0407: "trace.mnemonic").charAt(0));
0408: traceMenuItem.setText(Options.getInstance().getResource(
0409: "trace.text"));
0410: traceMenuItem
0411: .addActionListener(new MainFrame_traceMenuItem_actionAdapter(
0412: this ));
0413: statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
0414: statusBar.setPreferredSize(new Dimension(800, 30));
0415: statusBar.setLayout(flowLayout1);
0416: flowLayout1.setAlignment(FlowLayout.LEFT);
0417: flowLayout1.setHgap(0);
0418: flowLayout1.setVgap(0);
0419: desktop.setBackground(Color.lightGray);
0420: desktop.setBorder(BorderFactory.createLoweredBevelBorder());
0421: toolbar.add(queryButton);
0422: toolbar.add(listaButton);
0423: toolbar.add(schemaButton);
0424: toolbar.add(commitButton);
0425: toolbar.add(rollbackButton);
0426: menuFile.add(menuFileNewConn);
0427: menuFile.add(menuFileEndItem);
0428: menuFile.add(menuFileEndAllItem);
0429: menuFile.addSeparator();
0430: menuFile.add(menuFileRep);
0431: menuFile.addSeparator();
0432: menuFile.add(menuFileExit);
0433: menuHelp.add(menuHelpAbout);
0434: menuBar.add(menuFile);
0435: menuBar.add(sqlMenu);
0436: menuBar.add(dbMenu);
0437: menuBar.add(viewMenu);
0438: menuBar.add(winMenu);
0439: menuBar.add(menuHelp);
0440: this .setJMenuBar(menuBar);
0441: contentPane.add(toolbar, BorderLayout.NORTH);
0442: contentPane.add(statusBar, BorderLayout.SOUTH);
0443: contentPane.add(desktop, BorderLayout.CENTER);
0444: sqlMenu.add(currSqlMenuItem);
0445: sqlMenu.addSeparator();
0446: sqlMenu.add(explainPlanMenuItem);
0447: sqlMenu.add(importSQLMenuItem);
0448: sqlMenu.addSeparator();
0449: sqlMenu.add(recallListMenuItem);
0450: dbMenu.add(schemaBrowserMenuItem);
0451: dbMenu.add(sqlEditorMenuItem);
0452: dbMenu.add(dbSchemaMenuItem);
0453: dbMenu.addSeparator();
0454: dbMenu.add(traceMenuItem);
0455: dbMenu.addSeparator();
0456: dbMenu.add(commitMenuItem);
0457: dbMenu.add(rollbackMenuItem);
0458: viewMenu.add(optionsMenuItem);
0459: winMenu.add(closeAllMenuItem);
0460: winMenu.addSeparator();
0461: }
0462:
0463: //File | Exit action performed
0464: public void menuFileExit_actionPerformed(ActionEvent e) {
0465: if (JOptionPane
0466: .showConfirmDialog(this , Options.getInstance()
0467: .getResource("quit application?"), Options
0468: .getInstance().getResource("attention"),
0469: JOptionPane.YES_NO_OPTION,
0470: JOptionPane.QUESTION_MESSAGE) == 0) {
0471: System.exit(0);
0472: }
0473: }
0474:
0475: //File | Data Replication action performed
0476: public void menuFileRep_actionPerformed(ActionEvent e) {
0477: final JInternalFrame f = new ReplicationFrame(this );
0478: desktop.add(f);
0479: Dimension mdiSize = this .getSize();
0480: Dimension frameSize = f.getSize();
0481: if (frameSize.height > mdiSize.height) {
0482: frameSize.height = mdiSize.height;
0483: }
0484: if (frameSize.width > mdiSize.width) {
0485: frameSize.width = mdiSize.width;
0486: }
0487: f.setLocation((mdiSize.width - frameSize.width) / 2,
0488: (mdiSize.height - frameSize.height) / 2);
0489: f.setVisible(true);
0490:
0491: }
0492:
0493: //Help | About action performed
0494: public void menuHelpAbout_actionPerformed(ActionEvent e) {
0495: AboutBox dlg = new AboutBox(this );
0496: Dimension dlgSize = dlg.getPreferredSize();
0497: Dimension frmSize = getSize();
0498: Point loc = getLocation();
0499: dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
0500: (frmSize.height - dlgSize.height) / 2 + loc.y);
0501: dlg.setModal(true);
0502: dlg.show();
0503: }
0504:
0505: //Overridden so we can exit when window is closed
0506: protected void processWindowEvent(WindowEvent e) {
0507: super .processWindowEvent(e);
0508: if (e.getID() == WindowEvent.WINDOW_CLOSING) {
0509: menuFileExit_actionPerformed(null);
0510: }
0511: }
0512:
0513: public void createTableListFrame(DbConnectionUtil dbConnUtil) {
0514: TableListFrame frame = new TableListFrame(this , dbConnUtil);
0515: connWindowManager.addWindow(frame);
0516: }
0517:
0518: public void createSchemaFrame(DbConnectionUtil dbConnUtil) {
0519: SchemaFrame frame = new SchemaFrame(this , dbConnUtil);
0520: connWindowManager.addWindow(frame);
0521: }
0522:
0523: public void createSQLFrame(DbConnectionUtil dbConnUtil) {
0524: SQLFrame frame = new SQLFrame(this , dbConnUtil);
0525: connWindowManager.addWindow(frame);
0526: }
0527:
0528: void menuFileNewConn_actionPerformed(ActionEvent e) {
0529: final JInternalFrame f = new ConnectionFrame(this );
0530: desktop.add(f);
0531: Dimension mdiSize = this .getSize();
0532: Dimension frameSize = f.getSize();
0533: if (frameSize.height > mdiSize.height) {
0534: frameSize.height = mdiSize.height;
0535: }
0536: if (frameSize.width > mdiSize.width) {
0537: frameSize.width = mdiSize.width;
0538: }
0539: f.setLocation((mdiSize.width - frameSize.width) / 2,
0540: (mdiSize.height - frameSize.height) / 2);
0541: f.setVisible(true);
0542:
0543: new Thread() {
0544: public void run() {
0545: try {
0546: try {
0547: sleep(500);
0548: } catch (InterruptedException ex1) {
0549: }
0550: f.toFront();
0551: f.setSelected(true);
0552: f.requestFocus();
0553: } catch (PropertyVetoException ex) {
0554: }
0555: }
0556: }.start();
0557: }
0558:
0559: void menuFileEndAllItem_actionPerformed(ActionEvent e) {
0560: if (connWindowManager.getCurrentDbConnUtil() != null) {
0561: int answer = JOptionPane.showConfirmDialog(this , Options
0562: .getInstance().getResource(
0563: "close all connections windows?"),
0564: Options.getInstance().getResource(
0565: "close all connections"),
0566: JOptionPane.YES_NO_OPTION,
0567: JOptionPane.QUESTION_MESSAGE);
0568: if (answer == 0)
0569: connWindowManager.closeAll();
0570: }
0571: }
0572:
0573: void menuFileEndItem_actionPerformed(ActionEvent e) {
0574: if (connWindowManager.getCurrentDbConnUtil() != null) {
0575: int answer = JOptionPane.showConfirmDialog(this , Options
0576: .getInstance().getResource(
0577: "close connection and related windows?"),
0578: Options.getInstance().getResource(
0579: "close connection"),
0580: JOptionPane.YES_NO_OPTION,
0581: JOptionPane.QUESTION_MESSAGE);
0582: if (answer == 0)
0583: connWindowManager
0584: .closeConnectionAndWindows(connWindowManager
0585: .getCurrentDbConnUtil());
0586: }
0587: }
0588:
0589: void queryButton_actionPerformed(ActionEvent e) {
0590: if (connWindowManager.getCurrentDbConnUtil() != null)
0591: createSQLFrame(connWindowManager.getCurrentDbConnUtil());
0592: }
0593:
0594: void listaButton_actionPerformed(ActionEvent e) {
0595: if (connWindowManager.getCurrentDbConnUtil() != null)
0596: createTableListFrame(connWindowManager
0597: .getCurrentDbConnUtil());
0598: }
0599:
0600: void schemaButton_actionPerformed(ActionEvent e) {
0601: if (connWindowManager.getCurrentDbConnUtil() != null)
0602: createSchemaFrame(connWindowManager.getCurrentDbConnUtil());
0603: }
0604:
0605: void commitButton_actionPerformed(ActionEvent e) {
0606: try {
0607: if (connWindowManager.getCurrentDbConnUtil() != null) {
0608: connWindowManager.getCurrentDbConnUtil().getConn()
0609: .commit();
0610: }
0611: } catch (SQLException ex) {
0612: ex.printStackTrace();
0613: JOptionPane.showMessageDialog(this , Options.getInstance()
0614: .getResource("error on commit changes")
0615: + ":\n" + ex.getMessage(), Options.getInstance()
0616: .getResource("error"), JOptionPane.ERROR_MESSAGE);
0617: }
0618: }
0619:
0620: void rollbackButton_actionPerformed(ActionEvent e) {
0621: try {
0622: if (connWindowManager.getCurrentDbConnUtil() != null) {
0623: connWindowManager.getCurrentDbConnUtil().getConn()
0624: .rollback();
0625: }
0626: } catch (SQLException ex) {
0627: ex.printStackTrace();
0628: JOptionPane.showMessageDialog(this , Options.getInstance()
0629: .getResource("error on rollback changes")
0630: + ":\n" + ex.getMessage(), Options.getInstance()
0631: .getResource("error"), JOptionPane.ERROR_MESSAGE);
0632: }
0633: }
0634:
0635: void optionsMenuItem_actionPerformed(ActionEvent e) {
0636: new OptionsDialog(this );
0637: }
0638:
0639: void commitMenuItem_actionPerformed(ActionEvent e) {
0640: try {
0641: if (connWindowManager.getCurrentDbConnUtil() != null) {
0642: connWindowManager.getCurrentDbConnUtil().getConn()
0643: .commit();
0644: }
0645: } catch (SQLException ex) {
0646: ex.printStackTrace();
0647: JOptionPane.showMessageDialog(this , Options.getInstance()
0648: .getResource("error on commit changes")
0649: + ":\n" + ex.getMessage(), Options.getInstance()
0650: .getResource("error"), JOptionPane.ERROR_MESSAGE);
0651: }
0652: }
0653:
0654: void rollbackMenuItem_actionPerformed(ActionEvent e) {
0655: try {
0656: if (connWindowManager.getCurrentDbConnUtil() != null) {
0657: connWindowManager.getCurrentDbConnUtil().getConn()
0658: .rollback();
0659: }
0660: } catch (SQLException ex) {
0661: ex.printStackTrace();
0662: JOptionPane.showMessageDialog(this , Options.getInstance()
0663: .getResource("error on rollback changes")
0664: + ":\n" + ex.getMessage(), Options.getInstance()
0665: .getResource("error"), JOptionPane.ERROR_MESSAGE);
0666: }
0667: }
0668:
0669: void sqlEditorMenuItem_actionPerformed(ActionEvent e) {
0670: if (connWindowManager.getCurrentDbConnUtil() != null)
0671: createSQLFrame(connWindowManager.getCurrentDbConnUtil());
0672: }
0673:
0674: void schemaBrowserMenuItem_actionPerformed(ActionEvent e) {
0675: if (connWindowManager.getCurrentDbConnUtil() != null)
0676: createTableListFrame(connWindowManager
0677: .getCurrentDbConnUtil());
0678: }
0679:
0680: void dbSchemaMenuItem_actionPerformed(ActionEvent e) {
0681: if (connWindowManager.getCurrentDbConnUtil() != null)
0682: createSchemaFrame(connWindowManager.getCurrentDbConnUtil());
0683: }
0684:
0685: void closeAllMenuItem_actionPerformed(ActionEvent e) {
0686: if (connWindowManager.getCurrentDbConnUtil() != null) {
0687: int answer = JOptionPane
0688: .showConfirmDialog(
0689: this ,
0690: Options
0691: .getInstance()
0692: .getResource(
0693: "close all windows and related connections?"),
0694: Options.getInstance().getResource(
0695: "close all windows"),
0696: JOptionPane.YES_NO_OPTION,
0697: JOptionPane.QUESTION_MESSAGE);
0698: if (answer == 0)
0699: connWindowManager.closeAll();
0700: }
0701: }
0702:
0703: void currSqlMenuItem_actionPerformed(ActionEvent e) {
0704: if (connWindowManager.getCurrentFrame() != null
0705: && connWindowManager.getCurrentFrame() instanceof SQLFrame) {
0706: SQLFrame f = (SQLFrame) connWindowManager.getCurrentFrame();
0707: f.executeButton_actionPerformed(null);
0708: }
0709: }
0710:
0711: void explainPlanMenuItem_actionPerformed(ActionEvent e) {
0712: if (connWindowManager.getCurrentFrame() != null
0713: && connWindowManager.getCurrentFrame() instanceof SQLFrame) {
0714: SQLFrame f = (SQLFrame) connWindowManager.getCurrentFrame();
0715: f.explainPlanButton_actionPerformed(null);
0716: }
0717: }
0718:
0719: void importSQLMenuItem_actionPerformed(ActionEvent e) {
0720: if (connWindowManager.getCurrentFrame() != null
0721: && connWindowManager.getCurrentFrame() instanceof SQLFrame) {
0722: SQLFrame f = (SQLFrame) connWindowManager.getCurrentFrame();
0723: f.importSQLButton_actionPerformed(null);
0724: }
0725: }
0726:
0727: void recallListMenuItem_actionPerformed(ActionEvent e) {
0728: if (connWindowManager.getCurrentFrame() != null
0729: && connWindowManager.getCurrentFrame() instanceof SQLFrame) {
0730: SQLFrame f = (SQLFrame) connWindowManager.getCurrentFrame();
0731: f.executeHistoryButton_actionPerformed(null);
0732: }
0733: }
0734:
0735: void traceMenuItem_actionPerformed(ActionEvent e) {
0736: if (connWindowManager.getCurrentDbConnUtil() != null) {
0737: TraceSessionFrame frame = new TraceSessionFrame(this ,
0738: connWindowManager.getCurrentDbConnUtil());
0739: connWindowManager.addWindow(frame);
0740: }
0741: }
0742:
0743: }
0744:
0745: class MainFrame_menuFileExit_ActionAdapter implements ActionListener {
0746: MainFrame adaptee;
0747:
0748: MainFrame_menuFileExit_ActionAdapter(MainFrame adaptee) {
0749: this .adaptee = adaptee;
0750: }
0751:
0752: public void actionPerformed(ActionEvent e) {
0753: adaptee.menuFileExit_actionPerformed(e);
0754: }
0755: }
0756:
0757: class MainFrame_menuFileRep_ActionAdapter implements ActionListener {
0758: MainFrame adaptee;
0759:
0760: MainFrame_menuFileRep_ActionAdapter(MainFrame adaptee) {
0761: this .adaptee = adaptee;
0762: }
0763:
0764: public void actionPerformed(ActionEvent e) {
0765: adaptee.menuFileRep_actionPerformed(e);
0766: }
0767: }
0768:
0769: class MainFrame_menuHelpAbout_ActionAdapter implements ActionListener {
0770: MainFrame adaptee;
0771:
0772: MainFrame_menuHelpAbout_ActionAdapter(MainFrame adaptee) {
0773: this .adaptee = adaptee;
0774: }
0775:
0776: public void actionPerformed(ActionEvent e) {
0777: adaptee.menuHelpAbout_actionPerformed(e);
0778: }
0779: }
0780:
0781: class MainFrame_menuFileNewConn_actionAdapter implements
0782: java.awt.event.ActionListener {
0783: MainFrame adaptee;
0784:
0785: MainFrame_menuFileNewConn_actionAdapter(MainFrame adaptee) {
0786: this .adaptee = adaptee;
0787: }
0788:
0789: public void actionPerformed(ActionEvent e) {
0790: adaptee.menuFileNewConn_actionPerformed(e);
0791: }
0792: }
0793:
0794: class MainFrame_menuFileEndAllItem_actionAdapter implements
0795: java.awt.event.ActionListener {
0796: MainFrame adaptee;
0797:
0798: MainFrame_menuFileEndAllItem_actionAdapter(MainFrame adaptee) {
0799: this .adaptee = adaptee;
0800: }
0801:
0802: public void actionPerformed(ActionEvent e) {
0803: adaptee.menuFileEndAllItem_actionPerformed(e);
0804: }
0805: }
0806:
0807: class MainFrame_menuFileEndItem_actionAdapter implements
0808: java.awt.event.ActionListener {
0809: MainFrame adaptee;
0810:
0811: MainFrame_menuFileEndItem_actionAdapter(MainFrame adaptee) {
0812: this .adaptee = adaptee;
0813: }
0814:
0815: public void actionPerformed(ActionEvent e) {
0816: adaptee.menuFileEndItem_actionPerformed(e);
0817: }
0818: }
0819:
0820: class MainFrame_queryButton_actionAdapter implements
0821: java.awt.event.ActionListener {
0822: MainFrame adaptee;
0823:
0824: MainFrame_queryButton_actionAdapter(MainFrame adaptee) {
0825: this .adaptee = adaptee;
0826: }
0827:
0828: public void actionPerformed(ActionEvent e) {
0829: adaptee.queryButton_actionPerformed(e);
0830: }
0831: }
0832:
0833: class MainFrame_listaButton_actionAdapter implements
0834: java.awt.event.ActionListener {
0835: MainFrame adaptee;
0836:
0837: MainFrame_listaButton_actionAdapter(MainFrame adaptee) {
0838: this .adaptee = adaptee;
0839: }
0840:
0841: public void actionPerformed(ActionEvent e) {
0842: adaptee.listaButton_actionPerformed(e);
0843: }
0844: }
0845:
0846: class MainFrame_schemaButton_actionAdapter implements
0847: java.awt.event.ActionListener {
0848: MainFrame adaptee;
0849:
0850: MainFrame_schemaButton_actionAdapter(MainFrame adaptee) {
0851: this .adaptee = adaptee;
0852: }
0853:
0854: public void actionPerformed(ActionEvent e) {
0855: adaptee.schemaButton_actionPerformed(e);
0856: }
0857: }
0858:
0859: class MainFrame_commitButton_actionAdapter implements
0860: java.awt.event.ActionListener {
0861: MainFrame adaptee;
0862:
0863: MainFrame_commitButton_actionAdapter(MainFrame adaptee) {
0864: this .adaptee = adaptee;
0865: }
0866:
0867: public void actionPerformed(ActionEvent e) {
0868: adaptee.commitButton_actionPerformed(e);
0869: }
0870: }
0871:
0872: class MainFrame_rollbackButton_actionAdapter implements
0873: java.awt.event.ActionListener {
0874: MainFrame adaptee;
0875:
0876: MainFrame_rollbackButton_actionAdapter(MainFrame adaptee) {
0877: this .adaptee = adaptee;
0878: }
0879:
0880: public void actionPerformed(ActionEvent e) {
0881: adaptee.rollbackButton_actionPerformed(e);
0882: }
0883: }
0884:
0885: class MainFrame_optionsMenuItem_actionAdapter implements
0886: java.awt.event.ActionListener {
0887: MainFrame adaptee;
0888:
0889: MainFrame_optionsMenuItem_actionAdapter(MainFrame adaptee) {
0890: this .adaptee = adaptee;
0891: }
0892:
0893: public void actionPerformed(ActionEvent e) {
0894: adaptee.optionsMenuItem_actionPerformed(e);
0895: }
0896: }
0897:
0898: class MainFrame_commitMenuItem_actionAdapter implements
0899: java.awt.event.ActionListener {
0900: MainFrame adaptee;
0901:
0902: MainFrame_commitMenuItem_actionAdapter(MainFrame adaptee) {
0903: this .adaptee = adaptee;
0904: }
0905:
0906: public void actionPerformed(ActionEvent e) {
0907: adaptee.commitMenuItem_actionPerformed(e);
0908: }
0909: }
0910:
0911: class MainFrame_rollbackMenuItem_actionAdapter implements
0912: java.awt.event.ActionListener {
0913: MainFrame adaptee;
0914:
0915: MainFrame_rollbackMenuItem_actionAdapter(MainFrame adaptee) {
0916: this .adaptee = adaptee;
0917: }
0918:
0919: public void actionPerformed(ActionEvent e) {
0920: adaptee.rollbackMenuItem_actionPerformed(e);
0921: }
0922: }
0923:
0924: class MainFrame_sqlEditorMenuItem_actionAdapter implements
0925: java.awt.event.ActionListener {
0926: MainFrame adaptee;
0927:
0928: MainFrame_sqlEditorMenuItem_actionAdapter(MainFrame adaptee) {
0929: this .adaptee = adaptee;
0930: }
0931:
0932: public void actionPerformed(ActionEvent e) {
0933: adaptee.sqlEditorMenuItem_actionPerformed(e);
0934: }
0935: }
0936:
0937: class MainFrame_schemaBrowserMenuItem_actionAdapter implements
0938: java.awt.event.ActionListener {
0939: MainFrame adaptee;
0940:
0941: MainFrame_schemaBrowserMenuItem_actionAdapter(MainFrame adaptee) {
0942: this .adaptee = adaptee;
0943: }
0944:
0945: public void actionPerformed(ActionEvent e) {
0946: adaptee.schemaBrowserMenuItem_actionPerformed(e);
0947: }
0948: }
0949:
0950: class MainFrame_dbSchemaMenuItem_actionAdapter implements
0951: java.awt.event.ActionListener {
0952: MainFrame adaptee;
0953:
0954: MainFrame_dbSchemaMenuItem_actionAdapter(MainFrame adaptee) {
0955: this .adaptee = adaptee;
0956: }
0957:
0958: public void actionPerformed(ActionEvent e) {
0959: adaptee.dbSchemaMenuItem_actionPerformed(e);
0960: }
0961: }
0962:
0963: class MainFrame_closeAllMenuItem_actionAdapter implements
0964: java.awt.event.ActionListener {
0965: MainFrame adaptee;
0966:
0967: MainFrame_closeAllMenuItem_actionAdapter(MainFrame adaptee) {
0968: this .adaptee = adaptee;
0969: }
0970:
0971: public void actionPerformed(ActionEvent e) {
0972: adaptee.closeAllMenuItem_actionPerformed(e);
0973: }
0974: }
0975:
0976: class MainFrame_currSqlMenuItem_actionAdapter implements
0977: java.awt.event.ActionListener {
0978: MainFrame adaptee;
0979:
0980: MainFrame_currSqlMenuItem_actionAdapter(MainFrame adaptee) {
0981: this .adaptee = adaptee;
0982: }
0983:
0984: public void actionPerformed(ActionEvent e) {
0985: adaptee.currSqlMenuItem_actionPerformed(e);
0986: }
0987: }
0988:
0989: class MainFrame_explainPlanMenuItem_actionAdapter implements
0990: java.awt.event.ActionListener {
0991: MainFrame adaptee;
0992:
0993: MainFrame_explainPlanMenuItem_actionAdapter(MainFrame adaptee) {
0994: this .adaptee = adaptee;
0995: }
0996:
0997: public void actionPerformed(ActionEvent e) {
0998: adaptee.explainPlanMenuItem_actionPerformed(e);
0999: }
1000: }
1001:
1002: class MainFrame_importSQLMenuItem_actionAdapter implements
1003: java.awt.event.ActionListener {
1004: MainFrame adaptee;
1005:
1006: MainFrame_importSQLMenuItem_actionAdapter(MainFrame adaptee) {
1007: this .adaptee = adaptee;
1008: }
1009:
1010: public void actionPerformed(ActionEvent e) {
1011: adaptee.importSQLMenuItem_actionPerformed(e);
1012: }
1013: }
1014:
1015: class MainFrame_recallListMenuItem_actionAdapter implements
1016: java.awt.event.ActionListener {
1017: MainFrame adaptee;
1018:
1019: MainFrame_recallListMenuItem_actionAdapter(MainFrame adaptee) {
1020: this .adaptee = adaptee;
1021: }
1022:
1023: public void actionPerformed(ActionEvent e) {
1024: adaptee.recallListMenuItem_actionPerformed(e);
1025: }
1026: }
1027:
1028: class MainFrame_traceMenuItem_actionAdapter implements
1029: java.awt.event.ActionListener {
1030: MainFrame adaptee;
1031:
1032: MainFrame_traceMenuItem_actionAdapter(MainFrame adaptee) {
1033: this .adaptee = adaptee;
1034: }
1035:
1036: public void actionPerformed(ActionEvent e) {
1037: adaptee.traceMenuItem_actionPerformed(e);
1038: }
1039: }
|