1 19 20 package org.netbeans.modules.db.sql.execute.ui; 21 22 import java.io.IOException ; 23 import java.sql.SQLException ; 24 import org.netbeans.modules.db.sql.execute.SQLExecutionResult; 25 import org.netbeans.modules.db.sql.execute.SQLExecutionResults; 26 import org.openide.util.NbBundle; 27 28 32 public class SQLResultPanelModel { 33 34 private final ResultSetTableModel resultSetModel; 35 private final String affectedRows; 36 37 public static SQLResultPanelModel create(SQLExecutionResults executionResults) throws IOException , SQLException { 38 ResultSetTableModel resultSetModel = null; 39 String affectedRows = null; 40 41 if (executionResults != null && executionResults.size() > 0) { 42 SQLExecutionResult result = (SQLExecutionResult)executionResults.getResults().iterator().next(); 43 44 if (result.getResultSet() != null) { 45 resultSetModel = ResultSetTableModel.create(result.getResultSet()); 46 if (resultSetModel == null) { return null; 48 } 49 } else { 50 return new SQLResultPanelModel(); 51 } 52 } 53 54 return new SQLResultPanelModel(resultSetModel, affectedRows); 55 } 56 57 private SQLResultPanelModel() { 58 this(null, null); 59 } 60 61 private SQLResultPanelModel(ResultSetTableModel resultSetModel, String affectedRows) { 62 this.resultSetModel = resultSetModel; 63 this.affectedRows = affectedRows; 64 } 65 66 public ResultSetTableModel getResultSetModel() { 67 return resultSetModel; 68 } 69 70 public String getAffectedRows() { 71 return affectedRows; 72 } 73 74 public boolean isEmpty() { 75 return resultSetModel == null && affectedRows == null; 76 } 77 } 78 | Popular Tags |