EADS-3568 - When deploying files to secondary DB the notification dialog only shows about every other time
authorchrislovsund@netbeans.org
Thu, 28 Mar 2013 12:47:27 +0100
changeset 3684fdbdb29305e
parent 367 fffd72497d67
child 369 6235a04eba95
EADS-3568 - When deploying files to secondary DB the notification dialog only shows about every other time
fixed more bugs: when closing dialog it happened it deployed to wrong DB
refactoring: rename PlsqlCommit to PlsqlTransaction
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommit.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExplainPlanAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlTransaction.java
     1.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommit.java	Wed Mar 27 18:00:25 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,183 +0,0 @@
     1.4 -/*
     1.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 - *
     1.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
     1.8 - *
     1.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    1.10 - * Other names may be trademarks of their respective owners.
    1.11 - *
    1.12 - * The contents of this file are subject to the terms of either the GNU
    1.13 - * General Public License Version 2 only ("GPL") or the Common
    1.14 - * Development and Distribution License("CDDL") (collectively, the
    1.15 - * "License"). You may not use this file except in compliance with the
    1.16 - * License. You can obtain a copy of the License at
    1.17 - * http://www.netbeans.org/cddl-gplv2.html
    1.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    1.19 - * specific language governing permissions and limitations under the
    1.20 - * License.  When distributing the software, include this License Header
    1.21 - * Notice in each file and include the License file at
    1.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    1.23 - * particular file as subject to the "Classpath" exception as provided
    1.24 - * by Oracle in the GPL Version 2 section of the License file that
    1.25 - * accompanied this code. If applicable, add the following below the
    1.26 - * License Header, with the fields enclosed by brackets [] replaced by
    1.27 - * your own identifying information:
    1.28 - * "Portions Copyrighted [year] [name of copyright owner]"
    1.29 - *
    1.30 - * If you wish your version of this file to be governed by only the CDDL
    1.31 - * or only the GPL Version 2, indicate your decision by adding
    1.32 - * "[Contributor] elects to include this software in this distribution
    1.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    1.34 - * single choice of license, a recipient has the option to distribute
    1.35 - * your version of this file under either the CDDL, the GPL Version 2 or
    1.36 - * to extend the choice of license to its licensees as provided above.
    1.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    1.38 - * Version 2 license, then the option applies only if the new code is
    1.39 - * made subject to such option by the copyright holder.
    1.40 - *
    1.41 - * Contributor(s):
    1.42 - *
    1.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
    1.44 - */
    1.45 -package org.netbeans.modules.plsql.execution;
    1.46 -
    1.47 -import java.awt.event.ActionEvent;
    1.48 -import java.beans.PropertyChangeListener;
    1.49 -import java.beans.PropertyChangeSupport;
    1.50 -import java.util.ArrayList;
    1.51 -import java.util.List;
    1.52 -import javax.swing.AbstractAction;
    1.53 -import javax.swing.text.Document;
    1.54 -import org.netbeans.api.db.explorer.DatabaseConnection;
    1.55 -import org.openide.loaders.DataObject;
    1.56 -import org.openide.windows.InputOutput;
    1.57 -import org.netbeans.api.progress.ProgressHandle;
    1.58 -import org.netbeans.api.progress.ProgressHandleFactory;
    1.59 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    1.60 -import org.openide.cookies.EditorCookie;
    1.61 -import org.openide.util.Exceptions;
    1.62 -import org.openide.windows.IOProvider;
    1.63 -
    1.64 -/**
    1.65 - *
    1.66 - * @author SubSLK
    1.67 - */
    1.68 -public class PlsqlCommit extends AbstractAction {
    1.69 -
    1.70 -    private boolean commit;
    1.71 -    private DataObject dataObject;
    1.72 -    private static List<PlsqlCommit> instance = new ArrayList<PlsqlCommit>();
    1.73 -    public static final String PROP_commit = "PlsqlCommit";
    1.74 -    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    1.75 -
    1.76 -    private PlsqlCommit(DataObject obj) {
    1.77 -        commit = false; 
    1.78 -        dataObject = obj;
    1.79 -    }
    1.80 -
    1.81 -    public static PlsqlCommit getInstance(DataObject obj) {
    1.82 -        if (instance.isEmpty()) {
    1.83 -            instance.add(new PlsqlCommit(obj));
    1.84 -            return instance.get(0);
    1.85 -        } else {
    1.86 -            for (int i = 0; i < instance.size(); i++) {
    1.87 -                PlsqlCommit plsqlCommit = instance.get(i);
    1.88 -                if (plsqlCommit.dataObject.equals(obj)) {
    1.89 -                    return plsqlCommit;
    1.90 -                }
    1.91 -            }
    1.92 -            PlsqlCommit plsqlCommit = new PlsqlCommit(obj);
    1.93 -            instance.add(plsqlCommit);
    1.94 -            return plsqlCommit;
    1.95 -
    1.96 -        }
    1.97 -    }
    1.98 -
    1.99 -    public void setCommit(boolean commit_) {
   1.100 -        boolean oldCommit = commit;
   1.101 -        commit = commit_;
   1.102 -        changeSupport.firePropertyChange(PROP_commit, oldCommit, commit);
   1.103 -    }
   1.104 -
   1.105 -    public boolean getCommit() {
   1.106 -        return commit;
   1.107 -    }
   1.108 -    
   1.109 -    public void commitTransaction(DataObject fileObj, DatabaseConnection connection, DatabaseConnectionManager connectionProvider){
   1.110 -        EditorCookie edCookie = fileObj.getLookup().lookup(EditorCookie.class);
   1.111 -        Document document = edCookie.getDocument();        
   1.112 -        InputOutput io = null;
   1.113 -        DataObject obj = FileExecutionUtil.getDataObject(document);        
   1.114 -        
   1.115 -        ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...", this);
   1.116 -        handle.start();
   1.117 -
   1.118 -        try {
   1.119 -            io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
   1.120 -            if (!io.isClosed()) {
   1.121 -                io.getOut().println((new StringBuilder()).append("> Commit Statement successfully"));
   1.122 -            }
   1.123 -
   1.124 -            if (connection.getJDBCConnection() != null) {
   1.125 -                connectionProvider.commitRollbackTransactions(connection, true);
   1.126 -                setCommit(false);
   1.127 -            }
   1.128 -
   1.129 -        } catch (Exception ex) {
   1.130 -            io.getOut().println((new StringBuilder()).append(">!!! Error Commit Statement"));
   1.131 -            Exceptions.printStackTrace(ex);
   1.132 -        } finally {
   1.133 -            handle.finish();
   1.134 -        }
   1.135 -    }
   1.136 -    
   1.137 -    public void rollbackTransaction(DataObject obj, DatabaseConnection connection, DatabaseConnectionManager connectionProvider){
   1.138 -        InputOutput io = null;
   1.139 -        ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...", this);
   1.140 -        handle.start();
   1.141 -
   1.142 -        try {
   1.143 -            io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
   1.144 -            if (!io.isClosed()) {
   1.145 -                io.getOut().println((new StringBuilder()).append("> Rollback Statement successfully"));
   1.146 -            }
   1.147 -
   1.148 -            if (connection.getJDBCConnection() != null) {
   1.149 -                connectionProvider.commitRollbackTransactions(connection, false);  
   1.150 -                setCommit(false);
   1.151 -            }
   1.152 -
   1.153 -        } catch (Exception ex) {
   1.154 -            io.getOut().println((new StringBuilder()).append(">!!! Error Rollback Statement"));
   1.155 -            Exceptions.printStackTrace(ex);
   1.156 -        } finally {
   1.157 -            handle.finish();
   1.158 -        }
   1.159 -    }
   1.160 -    
   1.161 -    @Override
   1.162 -    public void addPropertyChangeListener(PropertyChangeListener listener) {
   1.163 -        PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
   1.164 -        for (int i = 0; i < listeners.length; i++) {
   1.165 -            if (listeners[i] == listener) {
   1.166 -                return;
   1.167 -            }
   1.168 -        }
   1.169 -        changeSupport.addPropertyChangeListener(listener);
   1.170 -    }
   1.171 -
   1.172 -    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
   1.173 -        PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
   1.174 -        for (int i = 0; i < listeners.length; i++) {
   1.175 -            if (listeners[i] == listener) {
   1.176 -                return;
   1.177 -            }
   1.178 -        }
   1.179 -        changeSupport.addPropertyChangeListener(propertyName, listener);
   1.180 -    }
   1.181 -
   1.182 -    @Override
   1.183 -    public void actionPerformed(ActionEvent e) {
   1.184 -       // throw new UnsupportedOperationException("Not supported yet.");
   1.185 -    }
   1.186 -    }
     2.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java	Wed Mar 27 18:00:25 2013 +0100
     2.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java	Thu Mar 28 12:47:27 2013 +0100
     2.3 @@ -47,14 +47,13 @@
     2.4  import java.beans.PropertyChangeEvent;
     2.5  import java.beans.PropertyChangeListener;
     2.6  import java.io.IOException;
     2.7 -import java.util.Arrays;
     2.8 -import java.util.List;
     2.9  import java.util.Locale;
    2.10  import javax.swing.AbstractAction;
    2.11  import javax.swing.Action;
    2.12  import javax.swing.ImageIcon;
    2.13  import javax.swing.JButton;
    2.14  import org.netbeans.api.db.explorer.DatabaseConnection;
    2.15 +import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
    2.16  import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    2.17  import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
    2.18  import org.openide.awt.ActionID;
    2.19 @@ -67,16 +66,16 @@
    2.20  import org.openide.util.actions.Presenter;
    2.21  
    2.22  @ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlCommitAction", category = "PLSQL")
    2.23 -@ActionRegistration(displayName = "#CTL_PlsqlCommit")
    2.24 +@ActionRegistration(displayName = "#CTL_PlsqlCommit", lazy = false)
    2.25  public class PlsqlCommitAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
    2.26  
    2.27 -    private static final List<String> EXTENSIONS = Arrays.asList(new String[]{"tdb"});
    2.28 -    private DataObject dataObject;
    2.29 +    private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
    2.30 +    private final DataObject dataObject;
    2.31      private DatabaseConnectionManager connectionProvider;
    2.32      private DatabaseConnection connection;
    2.33      private JButton button;
    2.34 -    PlsqlCommit commit; 
    2.35 -    private PropertyChangeListener EnableCommit;
    2.36 +    private final PlsqlTransaction transaction;
    2.37 +    private final PropertyChangeListener changeListener = new EnableCommit();
    2.38  
    2.39      public PlsqlCommitAction() {
    2.40          this(Utilities.actionsGlobalContext());
    2.41 @@ -87,41 +86,38 @@
    2.42          putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_commit.png")));
    2.43  
    2.44          dataObject = context.lookup(DataObject.class);
    2.45 +        transaction = PlsqlTransaction.getInstance(dataObject);
    2.46 +    }
    2.47  
    2.48 +    @Override
    2.49 +    public boolean isEnabled() {
    2.50          //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
    2.51 -        if (dataObject != null && (dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("spec")
    2.52 -                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("body")
    2.53 -                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
    2.54 -            if (!dataObject.getPrimaryFile().canWrite()) {
    2.55 -                dataObject = null;
    2.56 +        if (dataObject != null) {
    2.57 +            if (validator.isValidPackageDefault(dataObject) || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db")) {
    2.58 +                if (!dataObject.getPrimaryFile().canWrite()) {
    2.59 +                    return false;
    2.60 +                }
    2.61              }
    2.62 -        } else if (dataObject != null && !EXTENSIONS.contains(dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH))) {
    2.63 -            dataObject = null;
    2.64 +            if (!validator.isValidTDB(dataObject)) {
    2.65 +                return false;
    2.66 +            }
    2.67 +
    2.68 +            if (dataObject.getLookup().lookup(EditorCookie.class) == null) {
    2.69 +                return false;
    2.70 +            }
    2.71          }
    2.72 -
    2.73 -        if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
    2.74 -            dataObject = null;
    2.75 -        }
    2.76 -
    2.77 -        if (dataObject != null) {
    2.78 -            setEnabled(true);
    2.79 -           commit = PlsqlCommit.getInstance(dataObject);
    2.80 -        } else {
    2.81 -            setEnabled(false);
    2.82 -        }
    2.83 +        return true;
    2.84      }
    2.85  
    2.86      @Override
    2.87      public Action createContextAwareInstance(Lookup context) {
    2.88          return new PlsqlCommitAction(context);
    2.89 -
    2.90      }
    2.91  
    2.92      private void prepareConnection() {
    2.93          if (dataObject != null) {
    2.94              connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
    2.95          }
    2.96 -
    2.97          connection = dataObject.getLookup().lookup(DatabaseConnection.class);
    2.98      }
    2.99  
   2.100 @@ -138,28 +134,26 @@
   2.101          }
   2.102  
   2.103          saveIfModified(dataObject);
   2.104 -        commit.commitTransaction(dataObject, connection, connectionProvider);
   2.105 +        transaction.commitTransaction(connection, connectionProvider);
   2.106      }
   2.107 -    
   2.108 +
   2.109      @Override
   2.110      public Component getToolbarPresenter() {
   2.111          if (!isEnabled()) {
   2.112              return null;
   2.113 -        }     
   2.114 +        }
   2.115          button = DropDownButtonFactory.createDropDownButton(
   2.116                  new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), null);
   2.117          button.setAction(this);
   2.118 -        button.setSelected(!OptionsUtilities.isCommandWindowAutoCommitEnabled());
   2.119          button.setEnabled(false);
   2.120          button.setDisabledIcon(new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_commit_disable.png")));
   2.121 -        EnableCommit = new EnableCommit();
   2.122 -        commit.addPropertyChangeListener(EnableCommit);
   2.123 +        transaction.addPropertyChangeListener(changeListener);
   2.124          return button;
   2.125      }
   2.126 -    
   2.127 +
   2.128      private void saveIfModified(DataObject dataObj) {
   2.129          try {
   2.130 -            SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
   2.131 +            SaveCookie saveCookie = dataObj.getLookup().lookup(SaveCookie.class);
   2.132              if (saveCookie != null) {
   2.133                  saveCookie.save();
   2.134              }
   2.135 @@ -167,20 +161,16 @@
   2.136              Exceptions.printStackTrace(ex);
   2.137          }
   2.138      }
   2.139 -    
   2.140 +
   2.141      private class EnableCommit implements PropertyChangeListener {
   2.142  
   2.143 -        public EnableCommit() {}
   2.144 -
   2.145          @Override
   2.146          public void propertyChange(PropertyChangeEvent event) {
   2.147 -          if(!OptionsUtilities.isCommandWindowAutoCommitEnabled() && commit.getCommit()){
   2.148 -              button.setEnabled(true);
   2.149 -          }
   2.150 -          else
   2.151 -              button.setEnabled(false);
   2.152 +            if (!OptionsUtilities.isCommandWindowAutoCommitEnabled() && transaction.isOpen()) {
   2.153 +                button.setEnabled(true);
   2.154 +            } else {
   2.155 +                button.setEnabled(false);
   2.156 +            }
   2.157          }
   2.158 -
   2.159      }
   2.160  }
   2.161 -
     3.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java	Wed Mar 27 18:00:25 2013 +0100
     3.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java	Thu Mar 28 12:47:27 2013 +0100
     3.3 @@ -91,7 +91,7 @@
     3.4      private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
     3.5      private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
     3.6      private static final String TEST_BLOCK_NAME_PREFIX = "TestBlock:";
     3.7 -    private DataObject dataObject;
     3.8 +    private final DataObject dataObject;
     3.9      private PlsqlDataObject plsqlDataobject;
    3.10      private DatabaseConnectionManager connectionProvider;
    3.11      private DatabaseConnection connection;
    3.12 @@ -100,7 +100,7 @@
    3.13      private JButton button;
    3.14      private ActionListener buttonListener = new ButtonListener();
    3.15      private boolean autoCommit = true;
    3.16 -    PlsqlCommit commit;
    3.17 +    private final PlsqlTransaction transaction;
    3.18  
    3.19      public PlsqlExecuteAction() {
    3.20          this(Utilities.actionsGlobalContext());
    3.21 @@ -113,25 +113,27 @@
    3.22  
    3.23          dataObject = context.lookup(DataObject.class);
    3.24  
    3.25 -        //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
    3.26 -        if (dataObject != null && (validator.isValidPackageDefault(dataObject)
    3.27 -                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
    3.28 -            if (!dataObject.getPrimaryFile().canWrite()) {
    3.29 -                dataObject = null;
    3.30 -            }
    3.31 -        }
    3.32 -
    3.33 -        if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
    3.34 -            dataObject = null;
    3.35 -        }
    3.36 -
    3.37 -        setEnabled(dataObject != null);
    3.38          if (validator.isValidTDB(dataObject)) {
    3.39              autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
    3.40          }
    3.41 +        transaction = PlsqlTransaction.getInstance(dataObject);
    3.42 +    }
    3.43 +
    3.44 +    @Override
    3.45 +    public boolean isEnabled() {
    3.46 +        //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
    3.47          if (dataObject != null) {
    3.48 -            commit = PlsqlCommit.getInstance(dataObject);
    3.49 +            if (validator.isValidPackageDefault(dataObject) || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db")) {
    3.50 +                if (!dataObject.getPrimaryFile().canWrite()) {
    3.51 +                    return false;
    3.52 +                }
    3.53 +            }
    3.54 +
    3.55 +            if (dataObject.getLookup().lookup(EditorCookie.class) == null) {
    3.56 +                return false;
    3.57 +            }
    3.58          }
    3.59 +        return true;
    3.60      }
    3.61  
    3.62      @Override
    3.63 @@ -242,17 +244,17 @@
    3.64      private boolean setConnection(DatabaseConnection newConnection) {
    3.65          if (connectionHasChanged(newConnection)) {
    3.66  //            connection = dataObject.getLookup().lookup(DatabaseConnection.class);
    3.67 -            if (commit.getCommit()) {
    3.68 +            if (transaction != null && transaction.isOpen()) {
    3.69                  if (!OptionsUtilities.isDeployNoPromptEnabled()) {
    3.70 -                    String msg = "Commit transactions for " + connection.getDisplayName() + " ?";
    3.71 -                    String title = "Confirm!";
    3.72 +                    String msg = "Commit open transactions for " + connection.getDisplayName() + "?";
    3.73 +                    String title = "Commit open transaction?";
    3.74                      int dialogAnswer = JOptionPane.showOptionDialog(null, msg, title, JOptionPane.YES_NO_CANCEL_OPTION,
    3.75                              JOptionPane.QUESTION_MESSAGE, null, null, null);
    3.76  
    3.77                      if (dialogAnswer == JOptionPane.YES_OPTION) {
    3.78 -                        commit.commitTransaction(dataObject, connection, connectionProvider);
    3.79 +                        transaction.commitTransaction(connection, connectionProvider);
    3.80                      } else if (dialogAnswer == JOptionPane.NO_OPTION) {
    3.81 -                        commit.rollbackTransaction(dataObject, connection, connectionProvider);
    3.82 +                        transaction.rollbackTransaction(connection, connectionProvider);
    3.83                      } else {
    3.84                          return false;
    3.85                      }
    3.86 @@ -415,10 +417,8 @@
    3.87          }
    3.88  
    3.89          private void modifyConnection() {
    3.90 -
    3.91              plsqlDataobject = (PlsqlDataObject) dataObject;
    3.92              plsqlDataobject.modifyLookupDatabaseConnection(connection);
    3.93 -            dataObject = plsqlDataobject;
    3.94          }
    3.95      }
    3.96  
     4.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExplainPlanAction.java	Wed Mar 27 18:00:25 2013 +0100
     4.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExplainPlanAction.java	Thu Mar 28 12:47:27 2013 +0100
     4.3 @@ -67,100 +67,102 @@
     4.4  import org.openide.windows.OutputWriter;
     4.5  
     4.6  @ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExplainPlanAction", category = "PLSQL")
     4.7 -@ActionRegistration(displayName = "#CTL_PlsqlExplainPlanAction")
     4.8 +@ActionRegistration(displayName = "#CTL_PlsqlExplainPlanAction", lazy = false)
     4.9  public final class PlsqlExplainPlanAction extends CookieAction {
    4.10  
    4.11      @Override
    4.12 -   protected void performAction(Node[] activatedNodes) {
    4.13 -      EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
    4.14 -      DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
    4.15 -      if (editorCookie != null && dataObject != null) {
    4.16 -         try {
    4.17 -            DatabaseConnectionManager dbConnectionManager = DatabaseConnectionManager.getInstance(dataObject);
    4.18 -            if(dbConnectionManager==null) {
    4.19 -               JOptionPane.showMessageDialog(null, "Connect the project to a database");
    4.20 -               return;
    4.21 +    protected void performAction(Node[] activatedNodes) {
    4.22 +        EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
    4.23 +        DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
    4.24 +        if (editorCookie != null && dataObject != null) {
    4.25 +            try {
    4.26 +                DatabaseConnectionManager dbConnectionManager = DatabaseConnectionManager.getInstance(dataObject);
    4.27 +                if (dbConnectionManager == null) {
    4.28 +                    JOptionPane.showMessageDialog(null, "Connect the project to a database");
    4.29 +                    return;
    4.30 +                }
    4.31 +                DatabaseConnection dbConnection = dbConnectionManager.getPooledDatabaseConnection(true, true);
    4.32 +                try {
    4.33 +                    Connection connection = dbConnection.getJDBCConnection();
    4.34 +                    Document doc = editorCookie.getDocument();
    4.35 +                    if (connection != null) {
    4.36 +                        explainPlan(doc.getText(0, doc.getLength()), connection);
    4.37 +                    }
    4.38 +                } finally {
    4.39 +                    dbConnectionManager.releaseDatabaseConnection(dbConnection);
    4.40 +                }
    4.41 +            } catch (BadLocationException ex) {
    4.42 +                Exceptions.printStackTrace(ex);
    4.43              }
    4.44 -            DatabaseConnection dbConnection = dbConnectionManager.getPooledDatabaseConnection(true, true);
    4.45 -            try {
    4.46 -               Connection connection = dbConnection.getJDBCConnection();
    4.47 -               Document doc = editorCookie.getDocument();
    4.48 -               if (connection != null) {
    4.49 -                  explainPlan(doc.getText(0, doc.getLength()), connection);
    4.50 -               }
    4.51 -            } finally {
    4.52 -               dbConnectionManager.releaseDatabaseConnection(dbConnection);
    4.53 -            }
    4.54 -         } catch (BadLocationException ex) {
    4.55 -            Exceptions.printStackTrace(ex);
    4.56 -         }
    4.57 -      }
    4.58 -   }
    4.59 +        }
    4.60 +    }
    4.61  
    4.62      @Override
    4.63 -   protected int mode() {
    4.64 -      return CookieAction.MODE_EXACTLY_ONE;
    4.65 -   }
    4.66 +    protected int mode() {
    4.67 +        return CookieAction.MODE_EXACTLY_ONE;
    4.68 +    }
    4.69  
    4.70      @Override
    4.71 -   public String getName() {
    4.72 -      return NbBundle.getMessage(PlsqlExplainPlanAction.class, "CTL_PlsqlExplainPlanAction");
    4.73 -   }
    4.74 +    public String getName() {
    4.75 +        return NbBundle.getMessage(PlsqlExplainPlanAction.class, "CTL_PlsqlExplainPlanAction");
    4.76 +    }
    4.77  
    4.78      @Override
    4.79 -   protected Class[] cookieClasses() {
    4.80 -      return new Class[]{DataObject.class};
    4.81 -   }
    4.82 -
    4.83 -   @Override
    4.84 -   protected String iconResource() {
    4.85 -      return "org/netbeans/modules/plsql/execution/explain.png";
    4.86 -   }
    4.87 +    protected Class[] cookieClasses() {
    4.88 +        return new Class[]{DataObject.class};
    4.89 +    }
    4.90  
    4.91      @Override
    4.92 -   public HelpCtx getHelpCtx() {
    4.93 -      return HelpCtx.DEFAULT_HELP;
    4.94 -   }
    4.95 +    protected String iconResource() {
    4.96 +        return "org/netbeans/modules/plsql/execution/explain.png";
    4.97 +    }
    4.98  
    4.99 -   @Override
   4.100 -   protected boolean asynchronous() {
   4.101 -      return false;
   4.102 -   }
   4.103 +    @Override
   4.104 +    public HelpCtx getHelpCtx() {
   4.105 +        return HelpCtx.DEFAULT_HELP;
   4.106 +    }
   4.107  
   4.108 -   /**
   4.109 -    * Enable this action only for the SQL execution window
   4.110 -    * @param nodes
   4.111 -    * @return
   4.112 -    */
   4.113 -   @Override
   4.114 -   protected boolean enable(Node[] activatedNodes) {
   4.115 -      if (!super.enable(activatedNodes))
   4.116 -         return false;
   4.117 -      return activatedNodes[0].getLookup().lookup(DataObject.class).getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX);
   4.118 -   }
   4.119 +    @Override
   4.120 +    protected boolean asynchronous() {
   4.121 +        return false;
   4.122 +    }
   4.123  
   4.124 -   private void explainPlan(String sql, Connection con) {
   4.125 -      InputOutput io = IOProvider.getDefault().getIO("Explain Plan", true);
   4.126 -      io.select();
   4.127 -      try {
   4.128 -         sql = sql.trim();
   4.129 -         OutputWriter out = io.getOut();
   4.130 -         Statement stmt = con.createStatement();
   4.131 -         out.println("Explain plan for:");
   4.132 -         out.println("   " + sql.replaceAll("\n", "\n   "));
   4.133 -         if(sql.endsWith(";"))
   4.134 -            sql = sql.substring(0, sql.length()-1);
   4.135 -         stmt.execute("explain plan for " + sql);
   4.136 -         ResultSet rs = stmt.executeQuery("select plan_table_output from table(dbms_xplan.display)");
   4.137 -         while (rs.next()) {
   4.138 -            out.println(rs.getString(1));
   4.139 -         }
   4.140 -         stmt.close();
   4.141 -         out.close();
   4.142 -         io.getErr().close();
   4.143 -      } catch (SQLException ex) {
   4.144 -         io.getErr().println(ex.getMessage());
   4.145 -      }
   4.146 -   }
   4.147 +    /**
   4.148 +     * Enable this action only for the SQL execution window
   4.149 +     *
   4.150 +     * @param nodes
   4.151 +     * @return
   4.152 +     */
   4.153 +    @Override
   4.154 +    protected boolean enable(Node[] activatedNodes) {
   4.155 +        if (!super.enable(activatedNodes)) {
   4.156 +            return false;
   4.157 +        }
   4.158 +        return activatedNodes[0].getLookup().lookup(DataObject.class).getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX);
   4.159 +    }
   4.160 +
   4.161 +    private void explainPlan(String sql, Connection con) {
   4.162 +        InputOutput io = IOProvider.getDefault().getIO("Explain Plan", true);
   4.163 +        io.select();
   4.164 +        try {
   4.165 +            sql = sql.trim();
   4.166 +            OutputWriter out = io.getOut();
   4.167 +            Statement stmt = con.createStatement();
   4.168 +            out.println("Explain plan for:");
   4.169 +            out.println("   " + sql.replaceAll("\n", "\n   "));
   4.170 +            if (sql.endsWith(";")) {
   4.171 +                sql = sql.substring(0, sql.length() - 1);
   4.172 +            }
   4.173 +            stmt.execute("explain plan for " + sql);
   4.174 +            ResultSet rs = stmt.executeQuery("select plan_table_output from table(dbms_xplan.display)");
   4.175 +            while (rs.next()) {
   4.176 +                out.println(rs.getString(1));
   4.177 +            }
   4.178 +            stmt.close();
   4.179 +            out.close();
   4.180 +            io.getErr().close();
   4.181 +        } catch (SQLException ex) {
   4.182 +            io.getErr().println(ex.getMessage());
   4.183 +        }
   4.184 +    }
   4.185  }
   4.186 -
     5.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java	Wed Mar 27 18:00:25 2013 +0100
     5.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java	Thu Mar 28 12:47:27 2013 +0100
     5.3 @@ -430,7 +430,7 @@
     5.4          Connection con;
     5.5          Statement stm = null;
     5.6          String firstWord = null;
     5.7 -        PlsqlCommit commit = PlsqlCommit.getInstance((DataObject) object);
     5.8 +        PlsqlTransaction commit = PlsqlTransaction.getInstance((DataObject) object);
     5.9  
    5.10          //quick & dirty fix to avoid having output tabs for the SQL Execution window (unless there's an exception)
    5.11          //first check to see if this is a simple select statement and if so treat it separately.
    5.12 @@ -997,7 +997,7 @@
    5.13                  } else {
    5.14                      if (deploymentOk && (firstWord != null
    5.15                              && (firstWord.equalsIgnoreCase("INSERT") || firstWord.equalsIgnoreCase("UPDATE") || firstWord.equalsIgnoreCase("DELETE")))) {
    5.16 -                        commit.setCommit(true);
    5.17 +                        commit.open();
    5.18                      }
    5.19                  }
    5.20  
     6.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java	Wed Mar 27 18:00:25 2013 +0100
     6.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java	Thu Mar 28 12:47:27 2013 +0100
     6.3 @@ -47,17 +47,13 @@
     6.4  import java.beans.PropertyChangeEvent;
     6.5  import java.beans.PropertyChangeListener;
     6.6  import java.io.IOException;
     6.7 -import java.util.Arrays;
     6.8 -import java.util.List;
     6.9  import java.util.Locale;
    6.10  import javax.swing.AbstractAction;
    6.11  import javax.swing.Action;
    6.12  import javax.swing.ImageIcon;
    6.13  import javax.swing.JButton;
    6.14 -import javax.swing.text.Document;
    6.15  import org.netbeans.api.db.explorer.DatabaseConnection;
    6.16 -import org.netbeans.api.progress.ProgressHandle;
    6.17 -import org.netbeans.api.progress.ProgressHandleFactory;
    6.18 +import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
    6.19  import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    6.20  import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
    6.21  import org.openide.awt.ActionID;
    6.22 @@ -68,20 +64,18 @@
    6.23  import org.openide.loaders.DataObject;
    6.24  import org.openide.util.*;
    6.25  import org.openide.util.actions.Presenter;
    6.26 -import org.openide.windows.IOProvider;
    6.27 -import org.openide.windows.InputOutput;
    6.28  
    6.29  @ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlRollbackAction", category = "PLSQL")
    6.30 -@ActionRegistration(displayName = "#CTL_PlsqlRollback")
    6.31 +@ActionRegistration(displayName = "#CTL_PlsqlRollback", lazy = false)
    6.32  public class PlsqlRollbackAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
    6.33  
    6.34 -    private static final List<String> EXTENSIONS = Arrays.asList(new String[]{"tdb"});
    6.35 -    private DataObject dataObject;
    6.36 +    private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
    6.37 +    private final DataObject dataObject;
    6.38 +    private final PlsqlTransaction transaction;
    6.39      private DatabaseConnectionManager connectionProvider;
    6.40      private JButton button;
    6.41      private DatabaseConnection connection;
    6.42 -    PlsqlCommit commit;
    6.43 -    private PropertyChangeListener EnableRollback;
    6.44 +    private final PropertyChangeListener propertyChangeListener = new EnableRollback();
    6.45  
    6.46      public PlsqlRollbackAction() {
    6.47          this(Utilities.actionsGlobalContext());
    6.48 @@ -93,28 +87,27 @@
    6.49          putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_rollback.png")));
    6.50  
    6.51          dataObject = context.lookup(DataObject.class);
    6.52 +        transaction = PlsqlTransaction.getInstance(dataObject);
    6.53 +    }
    6.54  
    6.55 +    @Override
    6.56 +    public boolean isEnabled() {
    6.57          //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
    6.58 -        if (dataObject != null && (dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("spec")
    6.59 -                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("body")
    6.60 -                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
    6.61 -            if (!dataObject.getPrimaryFile().canWrite()) {
    6.62 -                dataObject = null;
    6.63 +        if (dataObject != null) {
    6.64 +            if (validator.isValidPackageDefault(dataObject) || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db")) {
    6.65 +                if (!dataObject.getPrimaryFile().canWrite()) {
    6.66 +                    return false;
    6.67 +                }
    6.68              }
    6.69 -        } else if (dataObject != null && !EXTENSIONS.contains(dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH))) {
    6.70 -            dataObject = null;
    6.71 +            if (!validator.isValidTDB(dataObject)) {
    6.72 +                return false;
    6.73 +            }
    6.74 +
    6.75 +            if (dataObject.getLookup().lookup(EditorCookie.class) == null) {
    6.76 +                return false;
    6.77 +            }
    6.78          }
    6.79 -
    6.80 -        if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
    6.81 -            dataObject = null;
    6.82 -        }
    6.83 -
    6.84 -        if (dataObject != null) {
    6.85 -            setEnabled(true); 
    6.86 -            commit = PlsqlCommit.getInstance(dataObject);
    6.87 -        } else {
    6.88 -            setEnabled(false);
    6.89 -        }
    6.90 +        return true;
    6.91      }
    6.92  
    6.93      @Override
    6.94 @@ -143,8 +136,7 @@
    6.95          }
    6.96  
    6.97          saveIfModified(dataObject);
    6.98 -        commit.rollbackTransaction(dataObject, connection, connectionProvider);
    6.99 -        commit.setCommit(false);
   6.100 +        transaction.rollbackTransaction(connection, connectionProvider);
   6.101      }
   6.102  
   6.103      @Override
   6.104 @@ -155,17 +147,15 @@
   6.105          button = DropDownButtonFactory.createDropDownButton(
   6.106                  new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), null);
   6.107          button.setAction(this);
   6.108 -        button.setSelected(!OptionsUtilities.isCommandWindowAutoCommitEnabled());
   6.109          button.setEnabled(false);
   6.110          button.setDisabledIcon(new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_rollback_disable.png")));
   6.111 -        EnableRollback = new EnableRollback();
   6.112 -        commit.addPropertyChangeListener(EnableRollback);
   6.113 +        transaction.addPropertyChangeListener(propertyChangeListener);
   6.114          return button;
   6.115      }
   6.116  
   6.117      private void saveIfModified(DataObject dataObj) {
   6.118          try {
   6.119 -            SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
   6.120 +            SaveCookie saveCookie = dataObj.getLookup().lookup(SaveCookie.class);
   6.121              if (saveCookie != null) {
   6.122                  saveCookie.save();
   6.123              }
   6.124 @@ -173,18 +163,16 @@
   6.125              Exceptions.printStackTrace(ex);
   6.126          }
   6.127      }
   6.128 -    
   6.129 +
   6.130      private class EnableRollback implements PropertyChangeListener {
   6.131  
   6.132 -        public EnableRollback() {}
   6.133 -
   6.134          @Override
   6.135          public void propertyChange(PropertyChangeEvent event) {
   6.136 -          if(!OptionsUtilities.isCommandWindowAutoCommitEnabled() && commit.getCommit()){
   6.137 -              button.setEnabled(true);
   6.138 -          }
   6.139 -          else
   6.140 -              button.setEnabled(false);
   6.141 +            if (!OptionsUtilities.isCommandWindowAutoCommitEnabled() && transaction.isOpen()) {
   6.142 +                button.setEnabled(true);
   6.143 +            } else {
   6.144 +                button.setEnabled(false);
   6.145 +            }
   6.146          }
   6.147      }
   6.148  }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlTransaction.java	Thu Mar 28 12:47:27 2013 +0100
     7.3 @@ -0,0 +1,180 @@
     7.4 +/*
     7.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     7.6 + *
     7.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
     7.8 + *
     7.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    7.10 + * Other names may be trademarks of their respective owners.
    7.11 + *
    7.12 + * The contents of this file are subject to the terms of either the GNU
    7.13 + * General Public License Version 2 only ("GPL") or the Common
    7.14 + * Development and Distribution License("CDDL") (collectively, the
    7.15 + * "License"). You may not use this file except in compliance with the
    7.16 + * License. You can obtain a copy of the License at
    7.17 + * http://www.netbeans.org/cddl-gplv2.html
    7.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    7.19 + * specific language governing permissions and limitations under the
    7.20 + * License.  When distributing the software, include this License Header
    7.21 + * Notice in each file and include the License file at
    7.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    7.23 + * particular file as subject to the "Classpath" exception as provided
    7.24 + * by Oracle in the GPL Version 2 section of the License file that
    7.25 + * accompanied this code. If applicable, add the following below the
    7.26 + * License Header, with the fields enclosed by brackets [] replaced by
    7.27 + * your own identifying information:
    7.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    7.29 + *
    7.30 + * If you wish your version of this file to be governed by only the CDDL
    7.31 + * or only the GPL Version 2, indicate your decision by adding
    7.32 + * "[Contributor] elects to include this software in this distribution
    7.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    7.34 + * single choice of license, a recipient has the option to distribute
    7.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    7.36 + * to extend the choice of license to its licensees as provided above.
    7.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    7.38 + * Version 2 license, then the option applies only if the new code is
    7.39 + * made subject to such option by the copyright holder.
    7.40 + *
    7.41 + * Contributor(s):
    7.42 + *
    7.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
    7.44 + */
    7.45 +package org.netbeans.modules.plsql.execution;
    7.46 +
    7.47 +import java.beans.PropertyChangeListener;
    7.48 +import java.beans.PropertyChangeSupport;
    7.49 +import java.util.ArrayList;
    7.50 +import java.util.List;
    7.51 +import org.netbeans.api.db.explorer.DatabaseConnection;
    7.52 +import org.openide.loaders.DataObject;
    7.53 +import org.openide.windows.InputOutput;
    7.54 +import org.netbeans.api.progress.ProgressHandle;
    7.55 +import org.netbeans.api.progress.ProgressHandleFactory;
    7.56 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    7.57 +import org.openide.util.Exceptions;
    7.58 +import org.openide.windows.IOProvider;
    7.59 +
    7.60 +/**
    7.61 + *
    7.62 + * @author SubSLK
    7.63 + */
    7.64 +public class PlsqlTransaction {
    7.65 +
    7.66 +    private final static List<PlsqlTransaction> instance = new ArrayList<PlsqlTransaction>();
    7.67 +    private boolean open;
    7.68 +    private final DataObject dataObject;
    7.69 +    public static final String PROP_commit = "PlsqlCommit";
    7.70 +    private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    7.71 +    private final InputOutput io;
    7.72 +
    7.73 +    public PlsqlTransaction(DataObject dataObject, InputOutput io) {
    7.74 +        open = false;
    7.75 +        this.dataObject = dataObject;
    7.76 +        this.io = io;
    7.77 +    }
    7.78 +
    7.79 +    public static PlsqlTransaction getInstance(DataObject object) {
    7.80 +        if (object == null) {
    7.81 +            return null;
    7.82 +        }
    7.83 +        InputOutput io = IOProvider.getDefault().getIO(object.getPrimaryFile().getNameExt(), false);
    7.84 +
    7.85 +        if (instance.isEmpty()) {
    7.86 +            instance.add(new PlsqlTransaction(object, io));
    7.87 +            return instance.get(0);
    7.88 +        } else {
    7.89 +            for (int i = 0; i < instance.size(); i++) {
    7.90 +                PlsqlTransaction plsqlCommit = instance.get(i);
    7.91 +                if (plsqlCommit.dataObject.equals(object)) {
    7.92 +                    return plsqlCommit;
    7.93 +                }
    7.94 +            }
    7.95 +            PlsqlTransaction plsqlCommit = new PlsqlTransaction(object, io);
    7.96 +            instance.add(plsqlCommit);
    7.97 +            return plsqlCommit;
    7.98 +        }
    7.99 +    }
   7.100 +
   7.101 +    void open() {
   7.102 +        setOpen(true);
   7.103 +    }
   7.104 +
   7.105 +    void close() {
   7.106 +        setOpen(false);
   7.107 +    }
   7.108 +
   7.109 +    private void setOpen(boolean newOpen) {
   7.110 +        boolean oldOpen = open;
   7.111 +        open = newOpen;
   7.112 +        changeSupport.firePropertyChange(PROP_commit, oldOpen, open);
   7.113 +    }
   7.114 +
   7.115 +    public boolean isOpen() {
   7.116 +        return open;
   7.117 +    }
   7.118 +
   7.119 +    public void commitTransaction(DatabaseConnection connection, DatabaseConnectionManager connectionProvider) {
   7.120 +
   7.121 +        ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...");
   7.122 +        handle.start();
   7.123 +
   7.124 +        try {
   7.125 +            if (!io.isClosed()) {
   7.126 +                io.getOut().println((new StringBuilder()).append("> Commit Statement successfully"));
   7.127 +            }
   7.128 +
   7.129 +            if (connection.getJDBCConnection() != null) {
   7.130 +                connectionProvider.commitRollbackTransactions(connection, true);
   7.131 +                close();
   7.132 +            }
   7.133 +
   7.134 +        } catch (Exception ex) {
   7.135 +            io.getOut().println((new StringBuilder()).append(">!!! Error Commit Statement"));
   7.136 +            Exceptions.printStackTrace(ex);
   7.137 +        } finally {
   7.138 +            handle.finish();
   7.139 +        }
   7.140 +    }
   7.141 +
   7.142 +    public void rollbackTransaction(DatabaseConnection connection, DatabaseConnectionManager connectionProvider) {
   7.143 +        ProgressHandle handle = ProgressHandleFactory.createHandle("Rollback database file...");
   7.144 +        handle.start();
   7.145 +
   7.146 +        try {
   7.147 +            if (!io.isClosed()) {
   7.148 +                io.getOut().println((new StringBuilder()).append("> Rollback Statement successfully"));
   7.149 +            }
   7.150 +
   7.151 +            if (connection.getJDBCConnection() != null) {
   7.152 +                connectionProvider.commitRollbackTransactions(connection, false);
   7.153 +                close();
   7.154 +            }
   7.155 +
   7.156 +        } catch (Exception ex) {
   7.157 +            io.getOut().println((new StringBuilder()).append(">!!! Error Rollback Statement"));
   7.158 +            Exceptions.printStackTrace(ex);
   7.159 +        } finally {
   7.160 +            handle.finish();
   7.161 +        }
   7.162 +    }
   7.163 +
   7.164 +    public void addPropertyChangeListener(PropertyChangeListener listener) {
   7.165 +        PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
   7.166 +        for (int i = 0; i < listeners.length; i++) {
   7.167 +            if (listeners[i] == listener) {
   7.168 +                return;
   7.169 +            }
   7.170 +        }
   7.171 +        changeSupport.addPropertyChangeListener(listener);
   7.172 +    }
   7.173 +
   7.174 +    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
   7.175 +        PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
   7.176 +        for (int i = 0; i < listeners.length; i++) {
   7.177 +            if (listeners[i] == listener) {
   7.178 +                return;
   7.179 +            }
   7.180 +        }
   7.181 +        changeSupport.addPropertyChangeListener(propertyName, listener);
   7.182 +    }
   7.183 +}