| @@ -1,6 +1,6 @@ | |||||
| <?xml version="1.0" encoding="ASCII"?> | <?xml version="1.0" encoding="ASCII"?> | ||||
| <application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_Lw_ZsEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.application"> | <application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_Lw_ZsEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.application"> | ||||
| <children xsi:type="basic:TrimmedWindow" xmi:id="_QDxdgEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.trimmedwindow.main" label="BGG Tool Another" width="700" height="800"> | |||||
| <children xsi:type="basic:TrimmedWindow" xmi:id="_QDxdgEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.trimmedwindow.main" label="BGG Tool Another" width="700" height="820"> | |||||
| <children xsi:type="basic:PartStack" xmi:id="_uw_Z4F9REeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.partstack.0"> | <children xsi:type="basic:PartStack" xmi:id="_uw_Z4F9REeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.partstack.0"> | ||||
| <children xsi:type="basic:Part" xmi:id="_co2toF9CEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.batmain" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.BatMain" label="Home"/> | <children xsi:type="basic:Part" xmi:id="_co2toF9CEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.batmain" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.BatMain" label="Home"/> | ||||
| <children xsi:type="basic:Part" xmi:id="_JsfvUF9YEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.fetch" visible="false" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.FetchPart" label="Fetch"> | <children xsi:type="basic:Part" xmi:id="_JsfvUF9YEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.fetch" visible="false" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.FetchPart" label="Fetch"> | ||||
| @@ -33,5 +33,9 @@ public class LocalDbAdapterService { | |||||
| return null; | return null; | ||||
| } | } | ||||
| public List<String> loadThingListNames() throws SQLException { | |||||
| return sqliteController.getThingLists(); | |||||
| } | |||||
| } | } | ||||
| @@ -9,6 +9,7 @@ import java.sql.PreparedStatement; | |||||
| import java.sql.ResultSet; | import java.sql.ResultSet; | ||||
| import java.sql.SQLException; | import java.sql.SQLException; | ||||
| import java.sql.Statement; | import java.sql.Statement; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | import java.util.List; | ||||
| import xyz.veronie.bgg.result.Thing; | import xyz.veronie.bgg.result.Thing; | ||||
| @@ -202,10 +203,66 @@ public class SqliteController { | |||||
| connection.setAutoCommit(true); | connection.setAutoCommit(true); | ||||
| } | } | ||||
| /// Retrieve the list of names of ThingLists. | |||||
| public List<String> getThingLists() throws SQLException { | |||||
| if(connection == null) { | |||||
| throw new RuntimeException("ERROR: Couldn't create Schema, connection is null."); | |||||
| } | |||||
| Statement stmt = null; | |||||
| stmt = connection.createStatement(); | |||||
| String str = "SELECT Name from ThingList order by Name asc"; | |||||
| System.out.println("TRACE: executeQuery: " + str); | |||||
| ResultSet res = stmt.executeQuery(str); | |||||
| List<String> listNames = new ArrayList<String>(); | |||||
| while(res.next()) { | |||||
| listNames.add(res.getString(1)); | |||||
| } | |||||
| stmt.close(); | |||||
| return listNames; | |||||
| } | |||||
| /// Retrieve all Things (with metadata, no details) for a given ThingList. | |||||
| public List<Thing> getThingList(String name) throws SQLException { | |||||
| if(connection == null) { | |||||
| throw new RuntimeException("ERROR: Couldn't create Schema, connection is null."); | |||||
| } | |||||
| Statement stmt = null; | |||||
| public List<Thing> getThingList(String name) { | |||||
| // TODO: implement this | |||||
| return null; | |||||
| stmt = connection.createStatement(); | |||||
| String str = "SELECT t.ThingId, t.Name, ImgUrl, ThumbUrl, Comment, NumPlays from Thing t " + | |||||
| "join ThingListToThing tltt on t.ThingId = tltt.ThingId " + | |||||
| "join ThingList tl on tl.ListId = tltt.ListId " + | |||||
| "where tl.Name = '" + name + "' order by t.Name asc"; | |||||
| System.out.println("TRACE: executeQuery: " + str); | |||||
| ResultSet res = stmt.executeQuery(str); | |||||
| List<Thing> thingList = new ArrayList<Thing>(); | |||||
| while(res.next()) { | |||||
| int id = res.getInt(1); | |||||
| ThingMetaData metaData = new ThingMetaData(id, | |||||
| res.getString(2), | |||||
| res.getString(3), | |||||
| res.getString(4), | |||||
| res.getString(5), | |||||
| res.getInt(6)); | |||||
| Thing thing = new Thing(id, metaData); | |||||
| thingList.add(thing); | |||||
| } | |||||
| stmt.close(); | |||||
| return thingList; | |||||
| } | } | ||||
| @@ -156,6 +156,8 @@ public class BggApi { | |||||
| // do something with the content | // do something with the content | ||||
| System.out.println(content.toString()); | System.out.println(content.toString()); | ||||
| ArrayList<Thing> output = parseThingMetas(content.toString()); | ArrayList<Thing> output = parseThingMetas(content.toString()); | ||||
| output.sort((thing1, thing2) -> thing1.getMetaData().getName().compareTo(thing2.getMetaData().getName())); | |||||
| return output; | return output; | ||||
| } | } | ||||
| @@ -107,6 +107,9 @@ public class ThingProvider { | |||||
| return things; | return things; | ||||
| } | } | ||||
| public List<String> getThingListNames() throws SQLException { | |||||
| return localDbAdapterService.loadThingListNames(); | |||||
| } | |||||
| } | } | ||||
| @@ -32,6 +32,4 @@ public interface EventConstants { | |||||
| String TOPIC_THINGS_SAVED = "THINGS_SAVED"; | String TOPIC_THINGS_SAVED = "THINGS_SAVED"; | ||||
| String TOPIC_THINGS_LOADED = "THINGS_LOADED"; | |||||
| } | } | ||||
| @@ -1,31 +1,45 @@ | |||||
| package xyz.veronie.bgg.ui.dialogs; | package xyz.veronie.bgg.ui.dialogs; | ||||
| import java.util.List; | |||||
| import org.eclipse.jface.dialogs.Dialog; | import org.eclipse.jface.dialogs.Dialog; | ||||
| import org.eclipse.jface.dialogs.IDialogConstants; | import org.eclipse.jface.dialogs.IDialogConstants; | ||||
| import org.eclipse.jface.viewers.ArrayContentProvider; | |||||
| import org.eclipse.jface.viewers.ColumnLabelProvider; | |||||
| import org.eclipse.jface.viewers.ISelectionChangedListener; | |||||
| import org.eclipse.jface.viewers.SelectionChangedEvent; | |||||
| import org.eclipse.jface.viewers.StructuredSelection; | |||||
| import org.eclipse.jface.viewers.TableViewer; | |||||
| import org.eclipse.jface.viewers.TableViewerColumn; | |||||
| import org.eclipse.swt.SWT; | import org.eclipse.swt.SWT; | ||||
| import org.eclipse.swt.events.MouseAdapter; | |||||
| import org.eclipse.swt.events.MouseEvent; | |||||
| import org.eclipse.swt.graphics.Point; | import org.eclipse.swt.graphics.Point; | ||||
| import org.eclipse.swt.layout.GridData; | |||||
| import org.eclipse.swt.layout.GridLayout; | import org.eclipse.swt.layout.GridLayout; | ||||
| import org.eclipse.swt.widgets.Button; | |||||
| import org.eclipse.swt.widgets.Composite; | import org.eclipse.swt.widgets.Composite; | ||||
| import org.eclipse.swt.widgets.Control; | import org.eclipse.swt.widgets.Control; | ||||
| import org.eclipse.swt.widgets.Label; | import org.eclipse.swt.widgets.Label; | ||||
| import org.eclipse.swt.widgets.Shell; | import org.eclipse.swt.widgets.Shell; | ||||
| import org.eclipse.swt.widgets.Table; | |||||
| import org.eclipse.swt.widgets.TableColumn; | |||||
| import org.eclipse.wb.swt.SWTResourceManager; | import org.eclipse.wb.swt.SWTResourceManager; | ||||
| import xyz.veronie.bgg.ui.helpers.BatColors; | import xyz.veronie.bgg.ui.helpers.BatColors; | ||||
| public class LoadGameListDialog extends Dialog { | public class LoadGameListDialog extends Dialog { | ||||
| private Button btnOk; | |||||
| private String selectedName; | private String selectedName; | ||||
| private List<String> thingLists; | |||||
| /** | /** | ||||
| * Create the dialog. | * Create the dialog. | ||||
| * @param parentShell | * @param parentShell | ||||
| */ | */ | ||||
| public LoadGameListDialog(Shell parentShell) { | |||||
| public LoadGameListDialog(Shell parentShell, List<String> thingLists) { | |||||
| super(parentShell); | super(parentShell); | ||||
| setShellStyle(SWT.APPLICATION_MODAL); | |||||
| this.thingLists = thingLists; | |||||
| setShellStyle(SWT.BORDER | SWT.RESIZE | SWT.APPLICATION_MODAL); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -34,10 +48,10 @@ public class LoadGameListDialog extends Dialog { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| protected Control createDialogArea(Composite parent) { | protected Control createDialogArea(Composite parent) { | ||||
| parent.setBackground(BatColors.getBackgroundColor()); | |||||
| parent.setBackground(BatColors.getButtonBgColor()); | |||||
| Composite container = (Composite) super.createDialogArea(parent); | Composite container = (Composite) super.createDialogArea(parent); | ||||
| container.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | container.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | ||||
| container.setBackground(BatColors.getBackgroundColor()); | |||||
| container.setBackground(BatColors.getButtonBgColor()); | |||||
| GridLayout gl_container = new GridLayout(1, false); | GridLayout gl_container = new GridLayout(1, false); | ||||
| gl_container.verticalSpacing = 24; | gl_container.verticalSpacing = 24; | ||||
| gl_container.marginWidth = 24; | gl_container.marginWidth = 24; | ||||
| @@ -50,27 +64,74 @@ public class LoadGameListDialog extends Dialog { | |||||
| container.setLayout(gl_container); | container.setLayout(gl_container); | ||||
| Label lblEnterAName = new Label(container, SWT.NONE); | Label lblEnterAName = new Label(container, SWT.NONE); | ||||
| lblEnterAName.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); | |||||
| lblEnterAName.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | lblEnterAName.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | ||||
| lblEnterAName.setText("Select a game list:"); | |||||
| lblEnterAName.setText("Select a game list to replace the current one:"); | |||||
| lblEnterAName.setBackground(BatColors.getButtonBgColor()); | |||||
| TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION ); | |||||
| Table table = tableViewer.getTable(); | |||||
| table.addMouseListener(new MouseAdapter() { | |||||
| @Override | |||||
| public void mouseDoubleClick(MouseEvent e) { | |||||
| closeDialogOk(); | |||||
| } | |||||
| }); | |||||
| table.setLinesVisible(true); | |||||
| // gd_tableGameList.heightHint = 466; | |||||
| table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); | |||||
| table.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | |||||
| final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); | |||||
| final TableColumn column = viewerColumn.getColumn(); | |||||
| column.setText("Game list name"); | |||||
| //column.setWidth(150); | |||||
| column.setAlignment(SWT.LEFT); | |||||
| column.setResizable(true); | |||||
| column.setMoveable(true); | |||||
| viewerColumn.setLabelProvider(new ColumnLabelProvider() { | |||||
| @Override | |||||
| public String getText(Object element) { | |||||
| return (String) element; | |||||
| } | |||||
| }); | |||||
| tableViewer.setContentProvider(new ArrayContentProvider()); | |||||
| tableViewer.setInput(thingLists); | |||||
| int selection = 0; | |||||
| tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(selection)), true); | |||||
| tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { | |||||
| // textField.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | |||||
| // textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); | |||||
| @Override | |||||
| public void selectionChanged(SelectionChangedEvent event) { | |||||
| selectedName = (String)event.getStructuredSelection().getFirstElement(); | |||||
| } | |||||
| }); | |||||
| column.pack(); | |||||
| return container; | return container; | ||||
| } | } | ||||
| private void closeDialogOk() { | |||||
| this.setReturnCode(OK); | |||||
| this.close(); | |||||
| } | |||||
| /** | /** | ||||
| * Create contents of the button bar. | * Create contents of the button bar. | ||||
| * @param parent | * @param parent | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| protected void createButtonsForButtonBar(Composite parent) { | protected void createButtonsForButtonBar(Composite parent) { | ||||
| parent.setBackground(BatColors.getBackgroundColor()); | |||||
| btnOk = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); | |||||
| btnOk.setEnabled(false); | |||||
| parent.setBackground(BatColors.getButtonBgColor()); | |||||
| createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); | |||||
| createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); | createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); | ||||
| } | } | ||||
| @@ -79,7 +140,7 @@ public class LoadGameListDialog extends Dialog { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| protected Point getInitialSize() { | protected Point getInitialSize() { | ||||
| return new Point(450, 300); | |||||
| return new Point(500, 500); | |||||
| } | } | ||||
| public String getSelectedName() { | public String getSelectedName() { | ||||
| @@ -14,10 +14,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; | |||||
| import org.eclipse.jface.viewers.SelectionChangedEvent; | import org.eclipse.jface.viewers.SelectionChangedEvent; | ||||
| import org.eclipse.jface.viewers.StructuredSelection; | import org.eclipse.jface.viewers.StructuredSelection; | ||||
| import org.eclipse.swt.SWT; | import org.eclipse.swt.SWT; | ||||
| import org.eclipse.swt.custom.ScrolledComposite; | |||||
| import org.eclipse.swt.events.FocusAdapter; | import org.eclipse.swt.events.FocusAdapter; | ||||
| import org.eclipse.swt.events.FocusEvent; | import org.eclipse.swt.events.FocusEvent; | ||||
| import org.eclipse.swt.layout.FillLayout; | |||||
| import org.eclipse.swt.layout.GridData; | import org.eclipse.swt.layout.GridData; | ||||
| import org.eclipse.swt.layout.GridLayout; | import org.eclipse.swt.layout.GridLayout; | ||||
| import org.eclipse.swt.widgets.Combo; | import org.eclipse.swt.widgets.Combo; | ||||
| @@ -31,7 +31,6 @@ import org.eclipse.swt.widgets.Label; | |||||
| import xyz.veronie.bgg.result.ResultConfigManager; | import xyz.veronie.bgg.result.ResultConfigManager; | ||||
| import xyz.veronie.bgg.types.EventConstants; | import xyz.veronie.bgg.types.EventConstants; | ||||
| import xyz.veronie.bgg.types.FamilyType; | import xyz.veronie.bgg.types.FamilyType; | ||||
| import xyz.veronie.bgg.ui.helpers.BatLayouts; | |||||
| /// These are the controls to retrieve thing IDs for a given family ID | /// These are the controls to retrieve thing IDs for a given family ID | ||||
| @Creatable | @Creatable | ||||
| @@ -46,7 +45,6 @@ public class FamilySourceFilter { | |||||
| public void postConstruct(Composite parent) { | public void postConstruct(Composite parent) { | ||||
| Composite mainCompo = new Composite(parent, SWT.FILL); | Composite mainCompo = new Composite(parent, SWT.FILL); | ||||
| GridLayout gl_mainCompo = new GridLayout(2, false); | GridLayout gl_mainCompo = new GridLayout(2, false); | ||||
| BatLayouts.applyZeroSpacing(gl_mainCompo); | |||||
| mainCompo.setLayout(gl_mainCompo); | mainCompo.setLayout(gl_mainCompo); | ||||
| mainCompo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | mainCompo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | ||||
| @@ -21,7 +21,6 @@ import org.eclipse.swt.widgets.Label; | |||||
| import xyz.veronie.bgg.result.ResultConfigManager; | import xyz.veronie.bgg.result.ResultConfigManager; | ||||
| import xyz.veronie.bgg.types.EventConstants; | import xyz.veronie.bgg.types.EventConstants; | ||||
| import xyz.veronie.bgg.ui.helpers.BatLayouts; | |||||
| /// These are the controls to retrieve thing IDs for a given family ID | /// These are the controls to retrieve thing IDs for a given family ID | ||||
| @Creatable | @Creatable | ||||
| @@ -37,7 +36,6 @@ public class GeeklistSourceFilter { | |||||
| public void postConstruct(Composite parent) { | public void postConstruct(Composite parent) { | ||||
| Composite mainCompo = new Composite(parent, SWT.FILL); | Composite mainCompo = new Composite(parent, SWT.FILL); | ||||
| GridLayout gl_mainCompo = new GridLayout(2, false); | GridLayout gl_mainCompo = new GridLayout(2, false); | ||||
| BatLayouts.applyZeroSpacing(gl_mainCompo); | |||||
| mainCompo.setLayout(gl_mainCompo); | mainCompo.setLayout(gl_mainCompo); | ||||
| mainCompo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | mainCompo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | ||||
| @@ -1,6 +1,9 @@ | |||||
| package xyz.veronie.bgg.ui.handlers; | package xyz.veronie.bgg.ui.handlers; | ||||
| import java.sql.SQLException; | |||||
| import java.util.List; | |||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||
| import org.eclipse.e4.core.di.annotations.CanExecute; | import org.eclipse.e4.core.di.annotations.CanExecute; | ||||
| @@ -23,23 +26,41 @@ public class HandleLoadGamelist { | |||||
| @Execute | @Execute | ||||
| public void execute(Shell shell, IEventBroker eventBroker) { | 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) { | |||||
| try { | |||||
| List<String> thingLists = thingProvider.getThingListNames(); | |||||
| if(thingLists.isEmpty()) { | |||||
| MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); | MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); | ||||
| msgBox.setMessage("Could not load game list."); | |||||
| msgBox.setMessage("There are no saved game lists."); | |||||
| msgBox.open(); | msgBox.open(); | ||||
| e.printStackTrace(); | |||||
| return; | |||||
| } | } | ||||
| LoadGameListDialog loadDialog = new LoadGameListDialog(shell, thingLists); | |||||
| loadDialog.open(); | |||||
| int returnCode = loadDialog.getReturnCode(); | |||||
| if(returnCode == Dialog.OK) { | |||||
| String name = loadDialog.getSelectedName(); | |||||
| try { | |||||
| thingProvider.loadList(name); | |||||
| eventBroker.post(EventConstants.TOPIC_RESULT_CHANGED, 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(); | |||||
| } | |||||
| } | |||||
| } catch (SQLException e) { | |||||
| MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); | |||||
| msgBox.setMessage("Could not load game lists."); | |||||
| msgBox.open(); | |||||
| e.printStackTrace(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -45,10 +45,9 @@ import xyz.veronie.bgg.ui.helpers.BatColors; | |||||
| import xyz.veronie.bgg.ui.helpers.BatLayouts; | import xyz.veronie.bgg.ui.helpers.BatLayouts; | ||||
| // TODO: load thing list from DB | |||||
| // TODO: import result.txt from bggtool | // TODO: import result.txt from bggtool | ||||
| // TODO: image sizes in result table | // TODO: image sizes in result table | ||||
| // TODO: display current thinglist name | |||||
| // TODO: fix encoding | |||||
| // TODO: fetch details from BGG | // TODO: fetch details from BGG | ||||
| // TODO: export to results.txt format | // TODO: export to results.txt format | ||||
| // TODO: generate PDF with nandeck | // TODO: generate PDF with nandeck | ||||
| @@ -59,6 +58,8 @@ import xyz.veronie.bgg.ui.helpers.BatLayouts; | |||||
| @SuppressWarnings("restriction") | @SuppressWarnings("restriction") | ||||
| public class BatMain { | public class BatMain { | ||||
| private static final String UNNAMED_LIST = "(unsaved list)"; | |||||
| private Table tableGameList; | private Table tableGameList; | ||||
| private TableViewer tableViewer; | private TableViewer tableViewer; | ||||
| @@ -71,6 +72,7 @@ public class BatMain { | |||||
| private Button btnSave; | private Button btnSave; | ||||
| private Button btnUndo; | private Button btnUndo; | ||||
| private Button btnExport; | private Button btnExport; | ||||
| private Label lblListName; | |||||
| @Inject | @Inject | ||||
| public BatMain() {} | public BatMain() {} | ||||
| @@ -165,6 +167,10 @@ public class BatMain { | |||||
| centerComposite.setLayout(gl_centerComposite); | centerComposite.setLayout(gl_centerComposite); | ||||
| centerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); | centerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); | ||||
| lblListName = new Label(centerComposite, SWT.NONE); | |||||
| lblListName.setText(UNNAMED_LIST); | |||||
| lblListName.setFont(SWTResourceManager.getFont("Segoe UI", 11, SWT.NORMAL)); | |||||
| lblListName.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); | |||||
| Composite tableComposite = new Composite(centerComposite, SWT.NONE); | Composite tableComposite = new Composite(centerComposite, SWT.NONE); | ||||
| tableComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); | tableComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); | ||||
| @@ -180,6 +186,7 @@ public class BatMain { | |||||
| GridData gd_tableGameList = new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1); | GridData gd_tableGameList = new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1); | ||||
| gd_tableGameList.heightHint = 466; | gd_tableGameList.heightHint = 466; | ||||
| tableGameList.setLayoutData(gd_tableGameList); | tableGameList.setLayoutData(gd_tableGameList); | ||||
| tableGameList.setFont(SWTResourceManager.getFont("Segoe UI", 10, SWT.NORMAL)); | |||||
| createColumns(tableViewer); | createColumns(tableViewer); | ||||
| tableViewer.setContentProvider(new ArrayContentProvider()); | tableViewer.setContentProvider(new ArrayContentProvider()); | ||||
| @@ -198,7 +205,6 @@ public class BatMain { | |||||
| } | } | ||||
| }); | }); | ||||
| Composite statusRow = new Composite(main, SWT.NONE); | Composite statusRow = new Composite(main, SWT.NONE); | ||||
| statusRow.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); | statusRow.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); | ||||
| GridLayout gl_statusRow = new GridLayout(1, false); | GridLayout gl_statusRow = new GridLayout(1, false); | ||||
| @@ -223,7 +229,7 @@ public class BatMain { | |||||
| private void createColumns(final TableViewer viewer) { | private void createColumns(final TableViewer viewer) { | ||||
| TableViewerColumn colThumbnail = createTableViewerColumn(Thing.ThumbHeader, 150, 0); | |||||
| TableViewerColumn colThumbnail = createTableViewerColumn(Thing.ThumbHeader, 120, 0); | |||||
| colThumbnail.setLabelProvider(new ColumnLabelProvider() { | colThumbnail.setLabelProvider(new ColumnLabelProvider() { | ||||
| @Override | @Override | ||||
| public Image getImage(Object element) { | public Image getImage(Object element) { | ||||
| @@ -291,17 +297,28 @@ public class BatMain { | |||||
| @Optional | @Optional | ||||
| private void subscribeTopicResultChanged | private void subscribeTopicResultChanged | ||||
| (@UIEventTopic(EventConstants.TOPIC_RESULT_CHANGED) | (@UIEventTopic(EventConstants.TOPIC_RESULT_CHANGED) | ||||
| String empty) { | |||||
| String listName) { | |||||
| System.out.println("TOPIC_RESULT_CHANGED"); | System.out.println("TOPIC_RESULT_CHANGED"); | ||||
| List<Thing> things = thingProvider.getThings(); | List<Thing> things = thingProvider.getThings(); | ||||
| tableViewer.setInput(things); | tableViewer.setInput(things); | ||||
| tableViewer.refresh(true); | |||||
| for (TableColumn column : tableViewer.getTable().getColumns()) { | |||||
| column.pack(); | |||||
| } | |||||
| tableViewer.refresh(true); | |||||
| if(things != null) { | if(things != null) { | ||||
| btnSave.setEnabled(things.size() != 0); | |||||
| if(!things.isEmpty()) { | |||||
| tableViewer.getTable().setTopIndex(0); | |||||
| } | |||||
| btnSave.setEnabled(things.size() != 0); | |||||
| btnExport.setEnabled(things.size() != 0); | btnExport.setEnabled(things.size() != 0); | ||||
| lblResultStatus.setText(Integer.toString(things.size()) + " items"); | lblResultStatus.setText(Integer.toString(things.size()) + " items"); | ||||
| lblResultStatus.redraw(); | lblResultStatus.redraw(); | ||||
| lblResultStatus.getParent().layout(); | lblResultStatus.getParent().layout(); | ||||
| if(listName != null && !listName.isEmpty()) { | |||||
| lblListName.setText("\"" + listName + "\""); | |||||
| } else { | |||||
| lblListName.setText(UNNAMED_LIST); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -312,7 +329,7 @@ public class BatMain { | |||||
| String listName) { | String listName) { | ||||
| System.out.println("TOPIC_THINGS_SAVED for game list '" + listName + "'."); | System.out.println("TOPIC_THINGS_SAVED for game list '" + listName + "'."); | ||||
| btnSave.setEnabled(false); | btnSave.setEnabled(false); | ||||
| // TODO: set list name in title | |||||
| lblListName.setText(listName); | |||||
| // TODO: implement undo | // TODO: implement undo | ||||
| } | } | ||||
| @@ -43,6 +43,7 @@ import xyz.veronie.bgg.ui.filters.FamilySourceFilter; | |||||
| import xyz.veronie.bgg.ui.filters.GeeklistSourceFilter; | import xyz.veronie.bgg.ui.filters.GeeklistSourceFilter; | ||||
| import xyz.veronie.bgg.ui.helpers.BatColors; | import xyz.veronie.bgg.ui.helpers.BatColors; | ||||
| import xyz.veronie.bgg.ui.helpers.BatLayouts; | import xyz.veronie.bgg.ui.helpers.BatLayouts; | ||||
| import org.eclipse.swt.widgets.Label; | |||||
| public class FetchPart { | public class FetchPart { | ||||
| @@ -86,6 +87,7 @@ public class FetchPart { | |||||
| private Composite geeklistPage; | private Composite geeklistPage; | ||||
| private Composite centerComposite; | private Composite centerComposite; | ||||
| private Label lblResultAction; | |||||
| @Inject | @Inject | ||||
| @@ -112,12 +114,15 @@ public class FetchPart { | |||||
| buttonRow.setLayout(gl_buttonRow); | buttonRow.setLayout(gl_buttonRow); | ||||
| btnBggUser = new Button(buttonRow, SWT.NONE); | btnBggUser = new Button(buttonRow, SWT.NONE); | ||||
| btnBggUser.setToolTipText("Fetch by bgg user"); | |||||
| btnBggUser.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_Meeple_60x60.png")); | btnBggUser.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_Meeple_60x60.png")); | ||||
| btnFamily = new Button(buttonRow, SWT.NONE); | btnFamily = new Button(buttonRow, SWT.NONE); | ||||
| btnFamily.setToolTipText("Fetch by family"); | |||||
| btnFamily.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_Family_60x60.png")); | btnFamily.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_Family_60x60.png")); | ||||
| btnGeeklist = new Button(buttonRow, SWT.NONE); | btnGeeklist = new Button(buttonRow, SWT.NONE); | ||||
| btnGeeklist.setToolTipText("Fetch by geeklist"); | |||||
| btnGeeklist.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_List_60x60.png")); | btnGeeklist.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_List_60x60.png")); | ||||
| @@ -145,6 +150,10 @@ public class FetchPart { | |||||
| applyComposite.setLayout(gl_applyComposite); | applyComposite.setLayout(gl_applyComposite); | ||||
| applyComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1)); | applyComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1)); | ||||
| lblResultAction = new Label(applyComposite, SWT.NONE); | |||||
| lblResultAction.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 5, 1)); | |||||
| lblResultAction.setText("How do you want to apply the result?"); | |||||
| Button btnReplace = new Button(applyComposite, SWT.NONE); | Button btnReplace = new Button(applyComposite, SWT.NONE); | ||||
| btnReplace.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/result_replace_60x60.png")); | btnReplace.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/result_replace_60x60.png")); | ||||
| btnReplace.setToolTipText("Replace"); | btnReplace.setToolTipText("Replace"); | ||||
| @@ -194,6 +203,8 @@ public class FetchPart { | |||||
| fetchEntries(ResultAction.SUBTRACT); | fetchEntries(ResultAction.SUBTRACT); | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||