Package net.sourceforge.squirrel_sql.plugins.mssql.gui

Examples of net.sourceforge.squirrel_sql.plugins.mssql.gui.GenerateSqlDialog


                        return;
                    }
                }
            }
           
      GenerateSqlDialog dlog = new GenerateSqlDialog(_session, _plugin, _dbObjs);
            dlog.preselectObjects(_dbObjs);
      dlog.pack();
      GUIUtils.centerWithinParent(dlog);
      if (!dlog.showGeneralSqlDialog())
                return;
           
            JFileChooser fc = new JFileChooser();
            if (dlog.getOneFile()) {
                ExtensionFilter ef = new ExtensionFilter();
           // i18n[mmsql.sqlScripts=SQL Scripts]
           ef.addExtension(s_stringMgr.getString("mmsql.sqlScripts"),"sql");
           // i18n[mmsql.textFiles=Text Files]
           ef.addExtension(s_stringMgr.getString("mmsql.textFiles"),"txt");
                fc.setFileFilter(ef);
            }
            else
                fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                           
            if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
               
                FileWriter fw = null;
               
                if (dlog.getOneFile()) {
                    fw = new FileWriter(fc.getSelectedFile(),false);
                   
                    if (dlog.getScriptDatabase())
                        fw.write(MssqlIntrospector.generateCreateDatabaseScript(_session.getSQLConnection().getCatalog(),_session.getSQLConnection()));
                   
                    if (dlog.getScriptUsersAndRoles())
                        fw.write(MssqlIntrospector.generateUsersAndRolesScript(_session.getSQLConnection().getCatalog(),_session.getSQLConnection()));
                }
               
                ArrayList<IDatabaseObjectInfo> objs = dlog.getSelectedItems();
                for (int i = 0; i < objs.size(); i++) {
                    IDatabaseObjectInfo oi = objs.get(i);
                   
                    if (!dlog.getOneFile())
                        fw = new FileWriter(fc.getSelectedFile() + java.io.File.separator + MssqlIntrospector.getFixedVersionedObjectName(oi.getSimpleName()) + ".txt",false);
                   
                    if (dlog.getGenerateDrop())
                        fw.write(MssqlIntrospector.generateDropScript(oi));
                   
                    if (dlog.getGenerateCreate()) {
                        String script = MssqlIntrospector.generateCreateScript(oi, _session.getSQLConnection(),dlog.getScriptConstraints());
                        fw.write(script);
                    }
                   
                    if (dlog.getScriptIndexes()) {
                        String script = MssqlIntrospector.generateCreateIndexesScript(oi, _session.getSQLConnection());
                        fw.write(script);
                    }
                   
                    if (dlog.getScriptTriggers()) {
                        String script = MssqlIntrospector.generateCreateTriggersScript(oi, _session.getSQLConnection());
                        fw.write(script);
                    }
                   
                    if (dlog.getScriptPermissions()) {
                        String script = MssqlIntrospector.generatePermissionsScript(oi, _session.getSQLConnection());
                        fw.write(script);
                    }
                   
                    if (!dlog.getOneFile())
                        fw.close();
                }
                if (dlog.getOneFile())
                    fw.close();
            }
    }
    catch (SQLException ex) {
            ex.printStackTrace();
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.plugins.mssql.gui.GenerateSqlDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.