diff --git a/xyz.veronie.bgg.ui/Application.e4xmi b/xyz.veronie.bgg.ui/Application.e4xmi
index 14cdd04..acc3aa7 100644
--- a/xyz.veronie.bgg.ui/Application.e4xmi
+++ b/xyz.veronie.bgg.ui/Application.e4xmi
@@ -16,7 +16,9 @@
+
+
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java
index 35079a6..59835aa 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java
@@ -1,11 +1,9 @@
package xyz.veronie.bgg.localdb;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.List;
import xyz.veronie.bgg.result.Thing;
-import xyz.veronie.bgg.result.ThingMetaData;
public class LocalDbAdapterService {
private SqliteController sqliteController;
@@ -28,10 +26,11 @@ public class LocalDbAdapterService {
sqliteController.addToThingList(name, things);
}
- /// retrieve a list of things with the given name
- public List retrieveThingList(String name) {
- // TODO: implement retrieve thing list
- return new ArrayList();
+ public List loadThingList(String name) throws SQLException {
+ if(sqliteController.hasThingList(name)) {
+ return sqliteController.getThingList(name);
+ }
+ return null;
}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java
index a194037..9b515c5 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java
@@ -203,5 +203,10 @@ public class SqliteController {
}
+ public List getThingList(String name) {
+ // TODO: implement this
+ return null;
+ }
+
}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java
index 4b430e7..4f3e7f0 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java
@@ -92,6 +92,12 @@ public class ThingProvider {
localDbAdapterService.storeThingList(this.things, listName);
}
+
+ public void loadList(String name) throws SQLException {
+ // TODO: handle unsaved current list
+ this.things = localDbAdapterService.loadThingList(name);
+ }
+
public int numberOfThings() {
return things.size();
}
@@ -101,5 +107,6 @@ public class ThingProvider {
return things;
}
+
}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/EventConstants.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/EventConstants.java
index 409dcff..b0907fd 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/EventConstants.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/EventConstants.java
@@ -32,4 +32,6 @@ public interface EventConstants {
String TOPIC_THINGS_SAVED = "THINGS_SAVED";
+ String TOPIC_THINGS_LOADED = "THINGS_LOADED";
+
}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/dialogs/LoadGameListDialog.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/dialogs/LoadGameListDialog.java
new file mode 100644
index 0000000..8c7357d
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/dialogs/LoadGameListDialog.java
@@ -0,0 +1,89 @@
+package xyz.veronie.bgg.ui.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wb.swt.SWTResourceManager;
+
+import xyz.veronie.bgg.ui.helpers.BatColors;
+
+public class LoadGameListDialog extends Dialog {
+ private Button btnOk;
+
+ private String selectedName;
+
+ /**
+ * Create the dialog.
+ * @param parentShell
+ */
+ public LoadGameListDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(SWT.APPLICATION_MODAL);
+ }
+
+ /**
+ * Create contents of the dialog.
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ parent.setBackground(BatColors.getBackgroundColor());
+ Composite container = (Composite) super.createDialogArea(parent);
+ container.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL));
+ container.setBackground(BatColors.getBackgroundColor());
+ GridLayout gl_container = new GridLayout(1, false);
+ gl_container.verticalSpacing = 24;
+ gl_container.marginWidth = 24;
+ gl_container.marginTop = 24;
+ gl_container.marginRight = 24;
+ gl_container.marginLeft = 24;
+ gl_container.marginHeight = 24;
+ gl_container.marginBottom = 24;
+ gl_container.horizontalSpacing = 24;
+ container.setLayout(gl_container);
+
+ Label lblEnterAName = new Label(container, SWT.NONE);
+ lblEnterAName.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL));
+ lblEnterAName.setText("Select a game list:");
+
+
+// textField.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL));
+// textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+
+ return container;
+ }
+
+ /**
+ * Create contents of the button bar.
+ * @param parent
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ parent.setBackground(BatColors.getBackgroundColor());
+
+ btnOk = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ btnOk.setEnabled(false);
+
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(450, 300);
+ }
+
+ public String getSelectedName() {
+ return selectedName;
+ }
+
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleLoadGamelist.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleLoadGamelist.java
new file mode 100644
index 0000000..cc27651
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleLoadGamelist.java
@@ -0,0 +1,51 @@
+
+package xyz.veronie.bgg.ui.handlers;
+
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+
+import xyz.veronie.bgg.result.ThingProvider;
+import xyz.veronie.bgg.types.EventConstants;
+import xyz.veronie.bgg.ui.dialogs.LoadGameListDialog;
+
+public class HandleLoadGamelist {
+
+ @Inject
+ ThingProvider thingProvider;
+
+ @Execute
+ public void execute(Shell shell, IEventBroker eventBroker) {
+
+ LoadGameListDialog loadDialog = new LoadGameListDialog(shell);
+ loadDialog.open();
+
+ int returnCode = loadDialog.getReturnCode();
+ if(returnCode == Dialog.OK) {
+ String name = loadDialog.getSelectedName();
+ try {
+ thingProvider.loadList(name);
+ eventBroker.post(EventConstants.TOPIC_THINGS_LOADED, name);
+ }
+ catch (Exception e) {
+ MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
+ msgBox.setMessage("Could not load game list.");
+ msgBox.open();
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ @CanExecute
+ public boolean canExecute() {
+ return thingProvider != null;
+ }
+
+}
\ No newline at end of file
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java
index 51d16fb..881ba43 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java
@@ -46,7 +46,8 @@ import xyz.veronie.bgg.ui.helpers.BatLayouts;
// TODO: load thing list from DB
-// TODO: image sizes
+// TODO: import result.txt from bggtool
+// TODO: image sizes in result table
// TODO: display current thinglist name
// TODO: fetch details from BGG
// TODO: export to results.txt format
@@ -132,9 +133,21 @@ public class BatMain {
btnSave.setEnabled(false);
Button btnLoad = new Button(buttonRow, SWT.NONE);
+ btnLoad.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ ParameterizedCommand cmd =
+ commandService.createCommand("xyz.veronie.bgg.ui.command.load", null);
+ if (handlerService.canExecute(cmd)){
+ handlerService.executeHandler(cmd);
+ }
+ }
+ });
btnLoad.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_open_60x60.png"));
btnLoad.setToolTipText("Load list of games");
+
+
btnUndo = new Button(buttonRow, SWT.NONE);
btnUndo.setToolTipText("Undo game list operation");
btnUndo.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_Undo_60x60.png"));