Commit e36382d8 authored by Matija Obreza's avatar Matija Obreza

Bulk

parent 32be3aca
......@@ -14,6 +14,10 @@
<name>3rd Party Eclipse</name>
<url>http://maven.thingml.org/thirdparty/</url>
</repository>
<repository>
<id>swt-repo</id>
<url>https://swt-repo.googlecode.com/svn/repo/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
......@@ -29,11 +33,9 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.cocoa.macosx.x86_64.4.3.swt
</groupId>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
<version>4.3</version>
<version>4.3.2</version>
</dependency>
</dependencies>
......
......@@ -21,9 +21,9 @@
<unpack>false</unpack>
<scope>runtime</scope>
<excludes>
<exclude>org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt:org.eclipse.swt.win32.win32.x86:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt:org.eclipse.swt.win32.win32.x86_64:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.gtk.linux.x86_64.4.3.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.3</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.win32.win32.x86:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.3.2</exclude>
</excludes>
</dependencySet>
</dependencySets>
......
......@@ -21,9 +21,9 @@
<unpack>false</unpack>
<scope>runtime</scope>
<excludes>
<exclude>org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt:org.eclipse.swt.win32.win32.x86:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt:org.eclipse.swt.win32.win32.x86_64:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.gtk.linux.x86.4.3.swt:org.eclipse.swt.gtk.linux.x86:jar:4.3</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.win32.win32.x86:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.gtk.linux.x86:jar:4.3.2</exclude>
</excludes>
</dependencySet>
</dependencySets>
......
......@@ -25,9 +25,9 @@
<unpack>false</unpack>
<scope>runtime</scope>
<excludes>
<exclude>org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt:org.eclipse.swt.win32.win32.x86_64:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.gtk.linux.x86.4.3.swt:org.eclipse.swt.gtk.linux.x86:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.gtk.linux.x86_64.4.3.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.3</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.gtk.linux.x86:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.3.2</exclude>
</excludes>
</dependencySet>
</dependencySets>
......
......@@ -25,9 +25,9 @@
<unpack>false</unpack>
<scope>runtime</scope>
<excludes>
<exclude>org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt:org.eclipse.swt.win32.win32.x86:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.gtk.linux.x86.4.3.swt:org.eclipse.swt.gtk.linux.x86:jar:4.3</exclude>
<exclude>org.eclipse.swt.org.eclipse.swt.gtk.linux.x86_64.4.3.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.3</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.win32.win32.x86:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.gtk.linux.x86:jar:4.3.2</exclude>
<exclude>org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.3.2</exclude>
</excludes>
</dependencySet>
</dependencySets>
......
......@@ -37,6 +37,19 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>swt-repo</id>
<url>https://swt-repo.googlecode.com/svn/repo/</url>
</repository>
<repository>
<id>thingml</id>
<name>3rd Party Eclipse</name>
<url>http://maven.thingml.org/thirdparty/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.genesys2</groupId>
......@@ -44,33 +57,24 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt
</groupId>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
<version>4.3</version>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt
</groupId>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>4.3</version>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.gtk.linux.x86_64.4.3.swt
</groupId>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>4.3</version>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.gtk.linux.x86.4.3.swt
</groupId>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86</artifactId>
<version>4.3</version>
<version>4.3.2</version>
</dependency>
</dependencies>
<name>Anno for Windows, Linux</name>
......
......@@ -22,6 +22,10 @@
<id>my-local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
<repository>
<id>swt-repo</id>
<url>https://swt-repo.googlecode.com/svn/repo/</url>
</repository>
<repository>
<id>thingml</id>
<name>3rd Party Eclipse</name>
......@@ -62,11 +66,9 @@
<version>1.0</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.cocoa.macosx.x86_64.4.3.swt
</groupId>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
<version>4.3</version>
<version>4.2.2</version>
<scope>provided</scope>
</dependency>
<!--<dependency> -->
......@@ -114,40 +116,25 @@
<artifactId>org.eclipse.jface.databinding</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.jface</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.swt</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.core.commands</artifactId>
<version>3.8.0</version>
</dependency>
<!-- <dependency> <groupId>org.eclipse.maven</groupId> <artifactId>org.eclipse.jface</artifactId>
<version>3.8.0</version> </dependency> -->
<!-- <dependency> <groupId>org.eclipse.maven</groupId> <artifactId>org.eclipse.swt</artifactId>
<version>3.8.0</version> </dependency> -->
<!-- <dependency> <groupId>org.eclipse.maven</groupId> <artifactId>org.eclipse.equinox.common</artifactId>
<version>3.8.0</version> </dependency> <dependency> <groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.core.commands</artifactId> <version>3.8.0</version>
</dependency> -->
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>com.ibm.icu</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
<version>3.8.0</version>
</dependency>
</dependency> <!-- <dependency> <groupId>org.eclipse.maven</groupId> <artifactId>org.eclipse.osgi.services</artifactId>
<version>3.8.0</version> </dependency> <dependency> <groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.osgi</artifactId> <version>3.8.0</version> </dependency> -->
<dependency>
<groupId>org.eclipse.maven</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.8.0</version>
<groupId>org.eclipse.jface</groupId>
<artifactId>org.eclipse.jface</artifactId>
<version>3.8.0.v20120521-2329</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
......@@ -184,7 +171,6 @@
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -116,7 +116,11 @@ public class RowConverter {
return split;
}
return valueFromPattern(stringValue.trim(), pattern, groupPattern);
String patVal = valueFromPattern(stringValue.trim(), pattern, groupPattern);
if (StringUtils.isBlank(patVal)) {
return null;
}
return patVal;
}
}
......
......@@ -204,12 +204,30 @@ public class AppWindow {
private static Image loadWorkspaceIcon;
private static Image saveWorkspaceIcon;
private static Image settingsIcon;
private static Image addDatabaseIcon;
static Image applicationIcon128;
private Tree filesTree;
private Display display;
private TreeViewer treeViewer;
private Table table;
private TableViewer tableViewer;
private CTabFolder tabFolder;
static {
AppWindow.archiveIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/archive.png")).createImage();
AppWindow.openPackageIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/openpackage.png")).createImage();
AppWindow.spreadsheetIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/spreadsheet.png")).createImage();
AppWindow.spreadsheetIcon16 = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/spreadsheet16.png")).createImage();
AppWindow.automapColumnsIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/automap.png")).createImage();
AppWindow.pushDataIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/pushdata.png")).createImage();
AppWindow.loadWorkspaceIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/load.png")).createImage();
AppWindow.saveWorkspaceIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/save.png")).createImage();
AppWindow.settingsIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/settings.png")).createImage();
AppWindow.addDatabaseIcon = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/database-add.png")).createImage();
AppWindow.applicationIcon128 = ImageDescriptor.createFromURL(AppWindow.class.getResource("/icon/appicon.png")).createImage();
}
/**
* Launch the application.
......@@ -218,6 +236,7 @@ public class AppWindow {
*/
public static void main(String[] args) {
Shell workspaceShell = new Shell();
WorkspaceDialog workspaceDialog = new WorkspaceDialog(workspaceShell);
Object workspacePath = workspaceDialog.open();
workspaceShell.dispose();
......@@ -261,7 +280,6 @@ public class AppWindow {
*/
public void open() {
this.display = Display.getDefault();
loadImages();
createContents();
shlGenesysMagic.open();
shlGenesysMagic.layout();
......@@ -276,18 +294,6 @@ public class AppWindow {
threadPool.shutdown();
}
private void loadImages() {
AppWindow.archiveIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/archive.png")).createImage();
AppWindow.openPackageIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/openpackage.png")).createImage();
AppWindow.spreadsheetIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/spreadsheet.png")).createImage();
AppWindow.spreadsheetIcon16 = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/spreadsheet16.png")).createImage();
AppWindow.automapColumnsIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/automap.png")).createImage();
AppWindow.pushDataIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/pushdata.png")).createImage();
AppWindow.loadWorkspaceIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/load.png")).createImage();
AppWindow.saveWorkspaceIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/save.png")).createImage();
AppWindow.settingsIcon = ImageDescriptor.createFromURL(this.getClass().getResource("/icon/settings.png")).createImage();
}
public static boolean isMac() {
if (System.getProperty("os.name").equals("Mac OS X")) {
return true;
......@@ -304,6 +310,7 @@ public class AppWindow {
shlGenesysMagic.setSize(744, 528);
shlGenesysMagic.setText("Genesys Magic");
shlGenesysMagic.setLayout(new BorderLayout(0, 0));
shlGenesysMagic.setImages(new Image[] { applicationIcon128 });
Menu menu = new Menu(shlGenesysMagic, SWT.BAR);
shlGenesysMagic.setMenuBar(menu);
......@@ -617,6 +624,7 @@ public class AppWindow {
}
});
tltmDatabase.setText("Add database");
tltmDatabase.setImage(AppWindow.addDatabaseIcon);
m_bindingContext = initDataBindings();
}
......
......@@ -114,13 +114,18 @@ public class DataSourceLoaderImpl implements DataSourceLoader {
}
@Override
public RowReader createRowReader(IDataSourceSheet sheet,IDataSource dataSource) throws IOException, UnsupportedDataFormatException {
public RowReader createRowReader(IDataSourceSheet sheet, IDataSource dataSource) throws IOException, UnsupportedDataFormatException {
if (sheet == null) {
throw new RuntimeException("dataSourceSheet cannot be null");
}
// Iterate over parsers and see if something comes out
if (sheet instanceof JdbcDataSourceSheet) {
JdbcDataSourceSheet jdbcSheet = (JdbcDataSourceSheet) sheet;
DatabaseSettings databaseSettings = ((JdbcDataSource)dataSource).getSettings();
return jdbcRowReader.createRowReader(jdbcSheet.getQuery(),databaseSettings);
DatabaseSettings databaseSettings = ((JdbcDataSource) dataSource).getSettings();
return jdbcRowReader.createRowReader(jdbcSheet.getQuery(), databaseSettings);
}
for (DataSourceParser parser : parsers) {
......
......@@ -14,11 +14,13 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
......@@ -47,6 +49,13 @@ public class PushDialog extends Dialog {
private static final Logger _log = Logger.getLogger(PushDialog.class);
protected static final int BATCH_SIZE = 50;
public static enum GenesysOp {
UPSERT, DELETE
}
private static Image deleteDataIcon;
private static Image parseDataIcon;
@Autowired
private Settings settings;
......@@ -62,9 +71,14 @@ public class PushDialog extends Dialog {
private IDataSourceSheet dataSourceSheet;
private ColumnDefs columnDefs;
private SwtLogAppender logAppender;
private IDataSource dataSource;
private IDataSource dataSource;
static {
deleteDataIcon = ImageDescriptor.createFromURL(PushDialog.class.getResource("/icon/delete.png")).createImage();
parseDataIcon = ImageDescriptor.createFromURL(PushDialog.class.getResource("/icon/parse.png")).createImage();
}
/**
/**
* Create the dialog.
*
* @param parent
......@@ -141,17 +155,38 @@ public class PushDialog extends Dialog {
}
});
tltmNewItem.setText("Parse all");
tltmNewItem.setImage(PushDialog.parseDataIcon);
ToolItem tltmPushToGenesys = new ToolItem(toolBar, SWT.NONE);
tltmPushToGenesys.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doPush();
if (SwtUtil.showYesNoPrompt(getParent(), "Confirmation required", "Push data to Genesys server?\n" + settings.getOauthSettings().getServerUrl())) {
_log.info("Upsert confirmed");
doPush(GenesysOp.UPSERT);
} else {
_log.info("Upsert canceled");
}
}
});
tltmPushToGenesys.setText("Upload");
tltmPushToGenesys.setImage(AppWindow.pushDataIcon);
ToolItem tltmRemove = new ToolItem(toolBar, SWT.NONE);
tltmRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (SwtUtil.showYesNoPrompt(getParent(), "Confirmation required", "Delete data from Genesys server?\n" + settings.getOauthSettings().getServerUrl())) {
_log.info("Delete confirmed");
doPush(GenesysOp.DELETE);
} else {
_log.info("Delete canceled");
}
}
});
tltmRemove.setText("Remove");
tltmRemove.setImage(PushDialog.deleteDataIcon);
ToolItem tltmRadioItemDebug = new ToolItem(toolBar, SWT.RADIO);
tltmRadioItemDebug.addSelectionListener(new SelectionAdapter() {
@Override
......@@ -188,7 +223,7 @@ public class PushDialog extends Dialog {
protected void doTrialRun() {
_log.info("Decoding data...");
try {
final RowReader rowReader = dataSourceLoader.createRowReader(dataSourceSheet,dataSource);
final RowReader rowReader = dataSourceLoader.createRowReader(dataSourceSheet, dataSource);
rowReader.setSkipRows(dataSourceSheet.getHeaderRowIndex() + 1);
executorService.execute(new Runnable() {
......@@ -247,7 +282,7 @@ public class PushDialog extends Dialog {
}
}
protected void doPush() {
protected void doPush(final GenesysOp operation) {
OAuthSettings oauthSettings = settings.getOauthSettings();
_log.info("Starting push to " + oauthSettings.getServerUrl());
......@@ -256,7 +291,7 @@ public class PushDialog extends Dialog {
// Ping the server
genesysClient.me();
final RowReader rowReader = dataSourceLoader.createRowReader(dataSourceSheet,dataSource);
final RowReader rowReader = dataSourceLoader.createRowReader(dataSourceSheet, dataSource);
rowReader.setSkipRows(dataSourceSheet.getHeaderRowIndex() + 1);
executorService.execute(new Runnable() {
......@@ -295,7 +330,7 @@ public class PushDialog extends Dialog {
synchronized (instCodeBatch) {
instCodeBatch.add(accnJson);
if (instCodeBatch.size() >= BATCH_SIZE) {
doAsyncPush(genesysClient, instCode, instCodeBatch);
doAsyncPush(operation, genesysClient, instCode, instCodeBatch);
}
}
} catch (GenesysJSONIncompleteException e) {
......@@ -311,7 +346,7 @@ public class PushDialog extends Dialog {
for (final String instCode : instCodeMap.keySet()) {
List<ObjectNode> accns = instCodeMap.get(instCode);
if (accns.size() > 0) {
doAsyncPush(genesysClient, instCode, accns);
doAsyncPush(operation, genesysClient, instCode, accns);
}
}
......@@ -366,15 +401,16 @@ public class PushDialog extends Dialog {
this.columnDefs = columnDefs;
}
private void doAsyncPush(final GenesysClient genesysClient, final String instCode, final Collection<ObjectNode> instCodeBatch) {
private void doAsyncPush(final GenesysOp operation, final GenesysClient genesysClient, final String instCode, final Collection<ObjectNode> instCodeBatch) {
if (instCodeBatch.size() == 0) {
_log.debug("Nothing to push");
return;
}
final ArrayList<ObjectNode> accns = new ArrayList<ObjectNode>(instCodeBatch);
instCodeBatch.clear();
executorService.execute(new Runnable() {
final ArrayList<ObjectNode> accns = new ArrayList<ObjectNode>(instCodeBatch);
final GenesysOp op = operation;
@Override
public void run() {
try {
......@@ -385,7 +421,11 @@ public class PushDialog extends Dialog {
}
}
genesysClient.updateAccessions(instCode, accns);
if (op == GenesysOp.UPSERT)
genesysClient.updateAccessions(instCode, accns);
else if (op == GenesysOp.DELETE)
genesysClient.deleteAccessions(instCode, GenesysClient.toArrayNode(accns));
} catch (OAuthAuthenticationException e) {
_log.error(e.getMessage(), e);
} catch (GenesysApiException e) {
......@@ -395,9 +435,11 @@ public class PushDialog extends Dialog {
}
}
});
instCodeBatch.clear();
}
public void setDataSource(IDataSource dataSource) {
this.dataSource = dataSource;
}
public void setDataSource(IDataSource dataSource) {
this.dataSource = dataSource;
}
}
......@@ -18,11 +18,13 @@ package org.genesys2.anno.gui;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.SQLException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
......@@ -159,8 +161,7 @@ public class SheetDisplay extends Composite {
private Text txtRegExp;
private Text txtGroupPattern;
private Text txtQueryName;
private TreeViewer treeViewer;
private IDataSource dataSource;
private IDataSource dataSource;
/**
* Create the composite.
......@@ -170,11 +171,10 @@ public class SheetDisplay extends Composite {
* @param parent
* @param style
*/
public SheetDisplay(IDataSource dataSource,final IDataSourceSheet dataSourceSheet, final Composite parent, final TreeViewer treeViewer, int style) {
public SheetDisplay(IDataSource dataSource, final IDataSourceSheet dataSourceSheet, final Composite parent, final TreeViewer treeViewer, int style) {
super(parent, SWT.NONE);
this.dsw.setDataSourceSheet(dataSourceSheet);
this.treeViewer = treeViewer;
this.dataSource=dataSource;
this.dataSource = dataSource;
addDisposeListener(new DisposeListener() {
@Override
......@@ -258,6 +258,9 @@ public class SheetDisplay extends Composite {
});
btnReloadQuery.setText("Reload");
new Label(compositeQuery, SWT.NONE);
new Label(compositeQuery, SWT.NONE);
new Label(compositeQuery, SWT.NONE);
if (!dsw.getDataSourceSheet().isSqlQuery()) {
tbtmQuery.dispose();
......@@ -448,7 +451,13 @@ public class SheetDisplay extends Composite {
lblCharacterSet.setText("Character set");
comboCharset = new Combo(compoCSV, SWT.NONE);
comboCharset.setItems(new String[] { "UTF-8", "US-ASCII", "Mac", "MacCentralEurope", "ISO-8859-1", "UTF-16", "windows-1250" });
{
SortedMap<String, Charset> availableCs = Charset.availableCharsets();
// for (String key : availableCs.keySet()) {
// System.err.println(key);
// }
comboCharset.setItems(availableCs.keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
}
comboCharset.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
comboCharset.select(0);
......@@ -514,22 +523,22 @@ public class SheetDisplay extends Composite {
});
}
private void executeSqlQuery(String query, DSW dsw) {
IDataSourceSheet currentSheet = dsw.getDataSourceSheet();
DatabaseSettings databaseSettings = ((JdbcDataSource)dataSource).getSettings();
private void executeSqlQuery(String query, DSW dsw) {
IDataSourceSheet currentSheet = dsw.getDataSourceSheet();
DatabaseSettings databaseSettings = ((JdbcDataSource) dataSource).getSettings();
final List<Object[]> rows;
try {
rows = jdbcRowReader.getRows(databaseSettings, query, 300);
if (rows != null) {
currentSheet.updateData(rows);
}
} catch (Throwable e) {
showMessageBox("SQL error", e);
_log.error(e.getMessage());
}
final List<Object[]> rows;
try {
rows = jdbcRowReader.getRows(databaseSettings, query, 300);
if (rows != null) {
currentSheet.updateData(rows);
}
} catch (Throwable e) {
showMessageBox("SQL error", e);
_log.error(e.getMessage());
}
}
}
protected void doDoubleClickOnRow(Object[] row) {
IDataSourceSheet dataSourceSheet = getDataSourceSheet();
......@@ -563,7 +572,7 @@ public class SheetDisplay extends Composite {