View Javadoc
1 /* 2 Bloof - visualize the evolution of your software project 3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de> 4 http://bloof.sf.net/ 5 6 This program is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along with 15 this program; if not, write to the Free Software Foundation, Inc., 16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 $RCSfile: OpenProject.java,v $ 19 Created on $Date: 2003/09/06 08:35:06 $ 20 */ 21 package net.sf.bloof; 22 23 import java.io.IOException; 24 import java.sql.Connection; 25 import java.sql.SQLException; 26 27 import net.sf.bloof.db.Database; 28 import net.sf.bloof.db.DbAccess; 29 import net.sf.bloof.db.McKoiControl; 30 import net.sf.bloof.db.PostgresControl; 31 import net.sf.bloof.events.BloofEvent; 32 import net.sf.bloof.scm.ScmAccessException; 33 import net.sf.bloof.util.ProgressEvent; 34 import net.sf.bloof.util.intl.Messages; 35 import net.sf.bloof.util.intl.Text; 36 37 /*** 38 * Opens an existing project 39 * @author Lukasz Pekacki <pekacki@users.sourceforge.net> 40 * @version $Id: OpenProject.java,v 1.1 2003/09/06 08:35:06 pekacki Exp $ 41 */ 42 public class OpenProject implements Runnable { 43 /*** 44 * Constructs a ImportProject class 45 * @param aDb database object 46 */ 47 public OpenProject(DbAccess aDb) { 48 mDb = aDb; 49 } 50 private synchronized void openProject() throws SQLException, ScmAccessException, IOException { 51 Bloof.propagateProgressEvent( 52 new ProgressEvent(Messages.getString(Text.CONNECTING_DATABASE), 10)); 53 if (mDb.equals(Bloof.INTERNAL_DATABASE)) { 54 /* start and connect to existing internal Database */ 55 Connection c; 56 try { 57 Bloof.propagateProgressEvent( 58 new ProgressEvent(Messages.getString(Text.READING_DATA), 60)); 59 c = McKoiControl.open(mDb); 60 Bloof.setDatabase(new Database(c)); 61 } catch (IOException e) { 62 throw new SQLException(Messages.getString(Text.COULD_NOT_OPEN_DB) + e.toString()); 63 } 64 65 } else if (PostgresControl.isMyUrl(mDb.getDatabaseUrl())) { 66 Bloof.propagateProgressEvent( 67 new ProgressEvent(Messages.getString(Text.READING_DATA), 60)); 68 Connection c = PostgresControl.open(mDb); 69 Bloof.setDatabase(new Database(c)); 70 } else if (McKoiControl.isMyUrl(mDb.getDatabaseUrl())) { 71 Bloof.propagateProgressEvent( 72 new ProgressEvent(Messages.getString(Text.READING_DATA), 60)); 73 Connection c = McKoiControl.openRemote(mDb); 74 Bloof.setDatabase(new Database(c)); 75 } else { 76 Bloof.fail( 77 Messages.getString(Text.NO_SUCH_DB) + mDb + " with url:" + mDb.getDatabaseUrl()); 78 throw new SQLException( 79 Messages.getString(Text.NO_SUCH_DB) + mDb + " with url:" + mDb.getDatabaseUrl()); 80 } 81 82 } 83 /*** 84 * Starts the import 85 * @see java.lang.Runnable#run( ) 86 */ 87 public void run() { 88 89 try { 90 openProject(); 91 } catch (SQLException e) { 92 Bloof.propagateBloofException( 93 new BloofException("SQL error on opening project." + e.toString())); 94 return; 95 96 } catch (IOException e) { 97 Bloof.propagateBloofException( 98 new BloofException("IO error on opening project." + e.toString())); 99 return; 100 } catch (ScmAccessException e) { 101 Bloof.propagateBloofException( 102 new BloofException("Scm access error on opening project." + e.toString())); 103 return; 104 } 105 Bloof.collectGarbage(); 106 Bloof.propagateProgressEvent(new ProgressEvent("Project opened.", 100)); 107 Bloof.propagateBloofEvent(BloofEvent.OPENED); 108 109 } 110 111 private DbAccess mDb; 112 }

This page was automatically generated by Maven