Commit f0f18312 authored by igoshin's avatar igoshin

#14051 fixed opening tab,added jdbc rows limit

parent 044814c7
......@@ -501,8 +501,8 @@ public class AppWindow {
IStructuredSelection thisSelection = (IStructuredSelection) e.getSelection();
Object selectedNode = thisSelection.getFirstElement();
if (selectedNode instanceof DataSourceSheet) {
final DataSourceSheet currentSheet = (DataSourceSheet) selectedNode;
if (selectedNode instanceof IDataSourceSheet) {
final IDataSourceSheet currentSheet = (IDataSourceSheet) selectedNode;
_log.debug("Doubleclick " + currentSheet);
int i = 0;
for (Control c : tabFolder.getTabList()) {
......@@ -518,34 +518,31 @@ public class AppWindow {
CTabItem newSheetTab = createTab(tabFolder, currentSheet);
// Load stuff
threadPool.execute(new Runnable() {
@Override
public void run() {
try {
final List<Object[]> rows = dataSourceLoader.loadRows(currentSheet, 200);
currentSheet.updateData(rows);
} catch (UnsupportedDataFormatException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
tabFolder.setSelection(newSheetTab);
} else if (selectedNode instanceof JdbcDataSourceSheet) {
final JdbcDataSourceSheet currentSheet = (JdbcDataSourceSheet) selectedNode;
CTabItem newSheetTab= createTab(tabFolder, currentSheet);
if (selectedNode instanceof DataSourceSheet) {
threadPool.execute(new Runnable() {
@Override
public void run() {
try {
final List<Object[]> rows = dataSourceLoader.loadRows(currentSheet, 200);
currentSheet.updateData(rows);
} catch (UnsupportedDataFormatException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
tabFolder.setSelection(newSheetTab);
}
}
});
sashForm_1.setWeights(new int[] { 4 });
}
});
sashForm_1.setWeights(new int[] { 4 });
ToolBar toolBar = new ToolBar(shlGenesysMagic, SWT.FLAT);
toolBar.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
......
......@@ -501,7 +501,7 @@ public class SheetDisplay extends Composite {
final List<Object[]> rows;
try {
rows = jdbcRowReader.getRows(query, url, user, password);
rows = jdbcRowReader.getRows(query, url, user, password,100);
if (rows != null) {
currentSheet.updateData(rows);
}
......
......@@ -13,13 +13,15 @@ import java.util.List;
public class JDBCRowReader {
private static final Logger _log = Logger.getLogger(JDBCRowReader.class);
public List<Object[]> getRows(String query, String url, String user, String password) throws SQLException {
public List<Object[]> getRows(String query, String url, String user, String password,int limit) throws SQLException {
List<Object[]> rows = new ArrayList<Object[]>();
Connection conn = ConnectionUtils.getConnection(url, user, password);
PreparedStatement ps = conn.prepareStatement(query);
ps.setMaxRows(limit);
ResultSet res = ps.executeQuery();
ResultSetMetaData metaData = res.getMetaData();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment