db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions ActionNewOJBRepository.java ActionOpenDatabase.java ActionOpenJavaClasspath.java ActionOpenOJBRepository.java ActionSaveAsOJBRepository.java ActionSaveOJBRepository.java
Date Wed, 05 May 2004 16:44:28 GMT
arminw      2004/05/05 09:44:28

  Added:       src/tools/org/apache/ojb/tools/mapping/reversedb2/actions
                        ActionNewOJBRepository.java ActionOpenDatabase.java
                        ActionOpenJavaClasspath.java
                        ActionOpenOJBRepository.java
                        ActionSaveAsOJBRepository.java
                        ActionSaveOJBRepository.java
  Log:
  fix fault
  wrong package structure used:
  org.apache.ojb.tools.reversdb
  org.apache.ojb.tools.reversdb2
  
  instead of
  org.apache.ojb.tools.mapping.reversdb
  org.apache.ojb.tools.mapping.reversdb2
  
  Revision  Changes    Path
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions/ActionNewOJBRepository.java
  
  Index: ActionNewOJBRepository.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb2.actions;
  import org.apache.ojb.broker.metadata.DescriptorRepository;
  import org.apache.ojb.tools.mapping.reversedb2.gui.JIFrmOJBRepository;
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /**
   * Opens a new JIFrmOBJRepository in the specified frame.
   * @author  Administrator
   */
  public class ActionNewOJBRepository extends javax.swing.AbstractAction
  {
      private javax.swing.JFrame containingFrame;
      /** Creates a new instance of ActionOpenOJBRepository */
      public ActionNewOJBRepository(javax.swing.JFrame pcontainingFrame)
      {
          this.containingFrame = pcontainingFrame;
          putValue(NAME, "New OJB Repository");
          putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_N));
      }
  
      public void actionPerformed (java.awt.event.ActionEvent actionEvent)
      {
          javax.swing.SwingUtilities.invokeLater(new Runnable()
          {
              public void run()
              {
                  try
                  {
                      // RepositoryPersistor persistor = new RepositoryPersistor ();
                      DescriptorRepository repository = new DescriptorRepository();
                      JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
                      containingFrame.getContentPane().add(frm);
                      frm.setVisible(true);
                  }
                  catch (Throwable t)
                  {
                      t.printStackTrace();
                  }
              }
          });
      }
  }
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions/ActionOpenDatabase.java
  
  Index: ActionOpenDatabase.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb2.actions;
  import org.apache.ojb.tools.mapping.reversedb2.gui.JDlgDBConnection;
  import org.apache.ojb.tools.mapping.reversedb2.gui.JIFrmDatabase;
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  
  /** First opens a JDlgDBConnection to get a JDBC connection and if this
   * was successful, a JIFrmDatabase is created with this connection and
   * added to the parentFrame specified in the constructor.
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
   * @version $Id: ActionOpenDatabase.java,v 1.1 2004/05/05 16:44:28 arminw Exp $
   */
  
  public class ActionOpenDatabase extends javax.swing.AbstractAction
  {
      
      javax.swing.JFrame containingFrame;
      /** Creates a new instance of ActionOpenDatabase, pcontainingFrame
       * is the parent frame for the dialog and the containing frame
       * for the internal frame created.
       * @param pcontainingFrame parent frame for the dialog, containing frame for the IFrame
       */
      public ActionOpenDatabase(javax.swing.JFrame pcontainingFrame) 
      {
          this.containingFrame = pcontainingFrame;
          putValue(NAME, "Open Database");
          putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_C));
      }
      
      /** Called to execute this action.
       * @param actionEvent
       */    
      public void actionPerformed(java.awt.event.ActionEvent actionEvent)
      {
          new Thread()
          {
              public void run()
              {
                  final java.sql.Connection conn = new JDlgDBConnection(containingFrame, false).showAndReturnConnection();
                  if (conn != null)
                  {
                      javax.swing.SwingUtilities.invokeLater(new Runnable()
                      {
                          public void run()
                          {
                              JIFrmDatabase frm = new JIFrmDatabase(conn);
                              containingFrame.getContentPane().add(frm);
                              frm.setVisible(true);
                          }
                      });
                  }
              }
          }.start();
      }
  }
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions/ActionOpenJavaClasspath.java
  
  Index: ActionOpenJavaClasspath.java
  ===================================================================
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.ojb.tools.mapping.reversedb2.actions;
  
  /**
   *
   * @author  Administrator
   */
  public class ActionOpenJavaClasspath {
      
      /** Creates a new instance of ActionOpenJavaClasspath */
      public ActionOpenJavaClasspath() {
      }
      
  }
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions/ActionOpenOJBRepository.java
  
  Index: ActionOpenOJBRepository.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb2.actions;
  import javax.swing.JFileChooser;
  
  import org.apache.ojb.broker.metadata.DescriptorRepository;
  import org.apache.ojb.broker.metadata.RepositoryPersistor;
  import org.apache.ojb.tools.mapping.reversedb2.Main;
  import org.apache.ojb.tools.mapping.reversedb2.gui.JIFrmOJBRepository;
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /**
   * Opens a new JIFrmOBJRepository in the specified frame.
   * @author  Administrator
   */
  public class ActionOpenOJBRepository extends javax.swing.AbstractAction
  {
      private javax.swing.JFrame containingFrame;
      /** Creates a new instance of ActionOpenOJBRepository */
      public ActionOpenOJBRepository(javax.swing.JFrame pcontainingFrame)
      {
          this.containingFrame = pcontainingFrame;
          putValue(NAME, "Open OJB Repository");
          putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_O));
      }
  
      public void actionPerformed (java.awt.event.ActionEvent actionEvent)
      {
  		String lastPath = Main.getProperties().getProperty("lastFileChooserPosition");
          javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser (lastPath);
          if (fileChooser.showOpenDialog(containingFrame)==JFileChooser.APPROVE_OPTION)
          {
              final java.io.File selectedFile = fileChooser.getSelectedFile();
  			Main.getProperties().setProperty("lastFileChooserPosition", selectedFile.getParentFile().getAbsolutePath());
              Main.getProperties().storeProperties("");
              javax.swing.SwingUtilities.invokeLater(new Runnable()
              {
                  public void run()
                  {
                      try
                      {
                          RepositoryPersistor persistor = new RepositoryPersistor ();
                          DescriptorRepository repository = persistor.readDescriptorRepository(selectedFile.getCanonicalPath());
                          JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
                          containingFrame.getContentPane().add(frm);
                          frm.setVisible(true);
                      }
                      catch (Throwable t)
                      {
                          t.printStackTrace();
                      }
                  }
              });
          }
      }
  }
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions/ActionSaveAsOJBRepository.java
  
  Index: ActionSaveAsOJBRepository.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb2.actions;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import javax.swing.JFileChooser;
  
  import org.apache.ojb.broker.metadata.DescriptorRepository;
  import org.apache.ojb.tools.mapping.reversedb2.Main;
  
  /**
   * Saves the given DescriptorRepository to a file selected by the use
   * @author  Administrator
   */
  public class ActionSaveAsOJBRepository extends javax.swing.AbstractAction
  {
      DescriptorRepository aRepository;
  
      /** Creates a new instance of ActionSaveOJBRepository */
      public ActionSaveAsOJBRepository(DescriptorRepository paRepository)
      {
          super("Save As...");
          putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_A));        
          aRepository = paRepository;
      }
      
      public void actionPerformed(java.awt.event.ActionEvent evt)
      {
  		String lastPath = Main.getProperties().getProperty("lastFileChooserPosition");
          javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser (lastPath);
          if (fileChooser.showSaveDialog((java.awt.Component)evt.getSource())==JFileChooser.APPROVE_OPTION)
          {
              final java.io.File selectedFile = fileChooser.getSelectedFile();
  			Main.getProperties().setProperty("lastFileChooserPosition", selectedFile.getParentFile().getAbsolutePath());
              Main.getProperties().storeProperties("");
  
              new ActionSaveOJBRepository(aRepository, selectedFile).actionPerformed(evt);
              
  /*            javax.swing.SwingUtilities.invokeLater(new Runnable()
              {
                  public void run()
                  {
                      try
                      {
                          RepositoryPersistor persistor = new RepositoryPersistor ();
                          DescriptorRepository repository = persistor.readFromFile(selectedFile.getCanonicalPath());
                          JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
                          containingFrame.getContentPane().add(frm);
                          frm.setVisible(true);
                      }
                      catch (Throwable t)
                      {
                          t.printStackTrace();
                      }
                  }
              });  
   */      
          }        
      }
  }
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb2/actions/ActionSaveOJBRepository.java
  
  Index: ActionSaveOJBRepository.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb2.actions;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import org.apache.ojb.broker.metadata.DescriptorRepository;
  
  /**
   * Saves the given DescriptorRepository to a file selected by the use
   * @author  Administrator
   */
  public class ActionSaveOJBRepository extends javax.swing.AbstractAction
  {
      DescriptorRepository aRepository;
      java.io.File theFile;
      /** Creates a new instance of ActionSaveOJBRepository */
      public ActionSaveOJBRepository(DescriptorRepository paRepository, java.io.File fileSaveTo)
      {
          super("Save");
          putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_S));
          aRepository = paRepository;
          theFile = fileSaveTo;
      }
      
      public void actionPerformed(java.awt.event.ActionEvent evt)
      {
          String xmlString = aRepository.toXML();
          try
          {
              if (!theFile.exists()) theFile.createNewFile();
              java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileOutputStream(
theFile ));
              pw.println(xmlString);
              pw.close();
          }
          // catches java.io.IOException and java.io.FileNotFoundException
          catch (Throwable t)
          {
              javax.swing.JOptionPane.showMessageDialog((java.awt.Component)evt.getSource(),
t.getMessage(), "Save repository.xml", javax.swing.JOptionPane.ERROR_MESSAGE);
          }
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message