http://wuselfuzz.de:3000/Veronie/BggToolAnother.git Conflicts: xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/PreparePart.javapull/2/head
| @@ -48,7 +48,7 @@ public class BggApi { | |||
| private static int RETRIES = 5; | |||
| public ArrayList<ThingMetaData> getThingsForUser(String user) throws IllegalArgumentException { | |||
| public ArrayList<Thing> getThingsForUser(String user) throws IllegalArgumentException { | |||
| ResultConfig resultConfig = configManager.getResultConfig(); | |||
| StringBuilder urlStr = new StringBuilder(); | |||
| @@ -85,7 +85,7 @@ public class BggApi { | |||
| } | |||
| public ArrayList<ThingMetaData> getThingsForGeeklist(int geeklistId) throws IllegalArgumentException { | |||
| public ArrayList<Thing> getThingsForGeeklist(int geeklistId) throws IllegalArgumentException { | |||
| ResultConfig resultConfig = configManager.getResultConfig(); | |||
| StringBuilder urlStr = new StringBuilder(); | |||
| @@ -94,7 +94,7 @@ public class BggApi { | |||
| return getThings(urlStr.toString()); | |||
| } | |||
| public ArrayList<ThingMetaData> getThingsForFamily(int familyId) throws IllegalArgumentException { | |||
| public ArrayList<Thing> getThingsForFamily(int familyId) throws IllegalArgumentException { | |||
| ResultConfig resultConfig = configManager.getResultConfig(); | |||
| StringBuilder urlStr = new StringBuilder(); | |||
| @@ -108,7 +108,7 @@ public class BggApi { | |||
| } | |||
| private ArrayList<ThingMetaData> getThings(String urlString) throws IllegalArgumentException { | |||
| private ArrayList<Thing> getThings(String urlString) throws IllegalArgumentException { | |||
| System.out.println("URL: " + urlString); | |||
| try { | |||
| @@ -141,7 +141,8 @@ public class BggApi { | |||
| // do something with the content | |||
| System.out.println(content.toString()); | |||
| ArrayList<ThingMetaData> output = parseThingMetas(content.toString()); | |||
| ArrayList<Thing> output = parseThingMetas(content.toString()); | |||
| return output; | |||
| } | |||
| @@ -165,8 +166,8 @@ public class BggApi { | |||
| private ArrayList<ThingMetaData> parseThingMetas(String content) throws IllegalArgumentException { | |||
| ArrayList<ThingMetaData> metas = new ArrayList<ThingMetaData>(); | |||
| private ArrayList<Thing> parseThingMetas(String content) throws IllegalArgumentException { | |||
| ArrayList<Thing> things = new ArrayList<Thing>(); | |||
| DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | |||
| try { | |||
| @@ -201,7 +202,8 @@ public class BggApi { | |||
| getValue(eElement, "comment"), | |||
| Integer.parseInt(getValue(eElement, "numplays")) | |||
| ); | |||
| metas.add(tmd); | |||
| Thing thing = new Thing(id, tmd); | |||
| things.add(thing); | |||
| } | |||
| } | |||
| // family has "type" | |||
| @@ -233,7 +235,8 @@ public class BggApi { | |||
| id, | |||
| eLink.getAttribute("value"), | |||
| "", "", "", null); | |||
| metas.add(tmd); | |||
| Thing thing = new Thing(id, tmd); | |||
| things.add(thing); | |||
| } | |||
| } | |||
| } | |||
| @@ -268,16 +271,17 @@ public class BggApi { | |||
| Integer id = Integer.parseInt(eElement.getAttribute("objectid")); | |||
| if(id != 0) { | |||
| ThingMetaData tmd = new ThingMetaData( | |||
| Integer.parseInt(eElement.getAttribute("objectid")), | |||
| id, | |||
| eElement.getAttribute("objectname"), | |||
| "", "", "", null); | |||
| metas.add(tmd); | |||
| Thing thing = new Thing(id, tmd); | |||
| things.add(thing); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return metas; | |||
| return things; | |||
| } catch (ParserConfigurationException e) { | |||
| e.printStackTrace(); | |||
| @@ -1,57 +1,124 @@ | |||
| package xyz.veronie.bgg.result; | |||
| public class Thing { | |||
| Integer id; | |||
| String name; | |||
| String designer; | |||
| String publisher; | |||
| String artist; | |||
| Integer yearpublished; | |||
| Integer minplayers; | |||
| Integer maxplayers; | |||
| Integer playingtime; | |||
| Integer minplaytime; | |||
| Integer maxplaytime; | |||
| Integer age; | |||
| Integer usersrated; | |||
| Integer average; | |||
| Float bayesaverage; | |||
| Integer rank; | |||
| Integer rank_wg; | |||
| Integer numcomments; | |||
| Integer numweights; | |||
| Float averageweight; | |||
| Float stddev; | |||
| Float median; | |||
| Boolean owned; | |||
| Boolean trading; | |||
| Boolean wanting; | |||
| Boolean wishing; | |||
| Float userrating; | |||
| String image; | |||
| Integer category; | |||
| Integer mechanic; | |||
| String comment; | |||
| Integer[] players; // 1 to 20 | |||
| String description; | |||
| // exp, | |||
| Integer basegameId; | |||
| Integer reimplementId; | |||
| String reimplement_name; | |||
| Integer reimplementedById; | |||
| String reimplementedByName; | |||
| Integer containsId; | |||
| String containsName; | |||
| Integer iscontained; | |||
| String iscontained_name; | |||
| Integer integration; | |||
| String integration_name; | |||
| Integer numplays; | |||
| Float price; | |||
| Float userweight; | |||
| Integer wishpriority; | |||
| Integer expansions; | |||
| String domain; | |||
| String family; | |||
| Float age_poll; | |||
| } | |||
| package xyz.veronie.bgg.result; | |||
| import java.io.File; | |||
| import java.net.MalformedURLException; | |||
| import java.net.URL; | |||
| import java.nio.file.Files; | |||
| import java.nio.file.LinkOption; | |||
| import java.nio.file.Path; | |||
| import java.nio.file.Paths; | |||
| import org.eclipse.jface.resource.ImageDescriptor; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.graphics.Image; | |||
| import org.eclipse.swt.graphics.ImageData; | |||
| import org.eclipse.swt.graphics.ImageLoader; | |||
| import xyz.veronie.bgg.ui.helpers.Constants; | |||
| import xyz.veronie.bgg.ui.helpers.Resources; | |||
| public class Thing { | |||
| private int id; | |||
| private ThingMetaData metaData; | |||
| private ThingDetails details; | |||
| // cache | |||
| private Image thumbImage; | |||
| public static final String IdHeader = "ID"; | |||
| public static final String ThumbHeader = ""; | |||
| public static final String NameHeader = "Name"; | |||
| public static final String DetailsHeader = "Details"; | |||
| public static final String ExportFlagHeader = "Export"; | |||
| public Thing(int id, ThingMetaData metaData) { | |||
| this.id = id; | |||
| this.metaData = metaData; | |||
| } | |||
| public int getId() { | |||
| return id; | |||
| } | |||
| public void setId(int id) { | |||
| this.id = id; | |||
| } | |||
| public ThingMetaData getMetaData() { | |||
| return metaData; | |||
| } | |||
| public void setMetaData(ThingMetaData metaData) { | |||
| this.metaData = metaData; | |||
| } | |||
| public ThingDetails getDetails() { | |||
| return details; | |||
| } | |||
| public void setDetails(ThingDetails details) { | |||
| this.details = details; | |||
| } | |||
| public Image getThumbnail() { | |||
| if(thumbImage == null) { | |||
| getThumbImage(id); | |||
| } | |||
| return thumbImage; | |||
| } | |||
| private void getThumbImage(int thingId) { | |||
| Path tmpDir = Resources.INSTANCE.getTmpDir(); | |||
| if(tmpDir != null) { | |||
| Path imageFile = Paths.get(Resources.INSTANCE.getThumbsDir().toString() | |||
| + File.separator + String.valueOf(thingId)); | |||
| if(Files.exists(imageFile, LinkOption.NOFOLLOW_LINKS)) { | |||
| thumbImage = Resources.INSTANCE.getResourceManager().createImage( | |||
| ImageDescriptor.createFromFile(Thing.class, imageFile.toString())); | |||
| } else { | |||
| try { | |||
| ImageDescriptor descriptor = ImageDescriptor.createFromURL( | |||
| new URL(metaData.getThumbURL())); | |||
| thumbImage = descriptor.createImage(); | |||
| ImageLoader saver = new ImageLoader(); | |||
| saver.data = new ImageData[] { thumbImage.getImageData() }; | |||
| saver.save(imageFile.toString(), SWT.IMAGE_PNG); | |||
| } catch (MalformedURLException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /// get field at idx, order of titles | |||
| public String getField(int idx) { | |||
| String returnStr; | |||
| switch(idx) { | |||
| case 0: | |||
| returnStr = String.valueOf(this.id); | |||
| break; | |||
| case 1: | |||
| returnStr = ""; | |||
| break; | |||
| case 2: | |||
| returnStr = this.getMetaData().getName(); | |||
| break; | |||
| case 3: | |||
| returnStr = (this.getDetails() != null) ? "yes" : "no"; | |||
| break; | |||
| case 4: | |||
| returnStr = this.getMetaData().getName(); | |||
| break; | |||
| default: | |||
| throw new ArrayIndexOutOfBoundsException( | |||
| "idx " + String.valueOf(idx) + " must be in [0,4]"); | |||
| } | |||
| return returnStr; | |||
| } | |||
| } | |||
| @@ -0,0 +1,57 @@ | |||
| package xyz.veronie.bgg.result; | |||
| public class ThingDetails { | |||
| Integer id; | |||
| String name; | |||
| String designer; | |||
| String publisher; | |||
| String artist; | |||
| Integer yearpublished; | |||
| Integer minplayers; | |||
| Integer maxplayers; | |||
| Integer playingtime; | |||
| Integer minplaytime; | |||
| Integer maxplaytime; | |||
| Integer age; | |||
| Integer usersrated; | |||
| Integer average; | |||
| Float bayesaverage; | |||
| Integer rank; | |||
| Integer rank_wg; | |||
| Integer numcomments; | |||
| Integer numweights; | |||
| Float averageweight; | |||
| Float stddev; | |||
| Float median; | |||
| Boolean owned; | |||
| Boolean trading; | |||
| Boolean wanting; | |||
| Boolean wishing; | |||
| Float userrating; | |||
| String image; | |||
| Integer category; | |||
| Integer mechanic; | |||
| String comment; | |||
| Integer[] players; // 1 to 20 | |||
| String description; | |||
| // exp, | |||
| Integer basegameId; | |||
| Integer reimplementId; | |||
| String reimplement_name; | |||
| Integer reimplementedById; | |||
| String reimplementedByName; | |||
| Integer containsId; | |||
| String containsName; | |||
| Integer iscontained; | |||
| String iscontained_name; | |||
| Integer integration; | |||
| String integration_name; | |||
| Integer numplays; | |||
| Float price; | |||
| Float userweight; | |||
| Integer wishpriority; | |||
| Integer expansions; | |||
| String domain; | |||
| String family; | |||
| Float age_poll; | |||
| } | |||
| @@ -14,7 +14,6 @@ public class ThingMetaData implements java.io.Serializable { | |||
| private String comment; | |||
| private Integer numPlays; | |||
| private static String[] titles = { "Id", "Name" }; | |||
| private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); | |||
| @@ -29,9 +28,7 @@ public class ThingMetaData implements java.io.Serializable { | |||
| this.setNumPlays(numPlays); | |||
| } | |||
| public static String[] getTitles() { | |||
| return titles; | |||
| } | |||
| public void addPropertyChangeListener(String propertyName, | |||
| PropertyChangeListener listener) { | |||
| @@ -42,29 +39,7 @@ public class ThingMetaData implements java.io.Serializable { | |||
| propertyChangeSupport.removePropertyChangeListener(listener); | |||
| } | |||
| /// get field at idx, order of titles | |||
| public String getField(int idx) { | |||
| if(idx >= titles.length) { | |||
| } | |||
| String returnStr; | |||
| switch(idx) { | |||
| case 0: | |||
| returnStr = String.valueOf(this.id); | |||
| break; | |||
| case 1: | |||
| returnStr = this.name; | |||
| break; | |||
| default: | |||
| throw new ArrayIndexOutOfBoundsException( | |||
| "idx " + String.valueOf(idx) + " must be in [0,1]"); | |||
| } | |||
| return returnStr; | |||
| } | |||
| public int getId() { | |||
| return id; | |||
| @@ -102,7 +77,7 @@ public class ThingMetaData implements java.io.Serializable { | |||
| propertyChangeSupport.firePropertyChange("thumb", this.thumbURL, | |||
| this.thumbURL = thumbURL); | |||
| } | |||
| public int getNumPlays() { | |||
| return numPlays; | |||
| } | |||
| @@ -20,55 +20,58 @@ public class ThingProvider { | |||
| private List<ThingMetaData> thingMetas; | |||
| public ThingProvider() {} | |||
| private List<Thing> things; | |||
| @PostConstruct | |||
| public void init() { | |||
| localDbAdapterService = new LocalDbAdapterService(); | |||
| thingMetas = new ArrayList<ThingMetaData>(); | |||
| things = new ArrayList<Thing>(); | |||
| } | |||
| /// replace current list with new list | |||
| public void replaceThingMetas(ArrayList<ThingMetaData> metas) { | |||
| this.thingMetas = metas; | |||
| public void replaceThings(ArrayList<Thing> things) { | |||
| this.things = things; | |||
| } | |||
| /// add things from argument to current list iff their ID does not exist yet | |||
| public void addThingMetas(ArrayList<ThingMetaData> metas) { | |||
| for(ThingMetaData tmd : metas) { | |||
| public void addThings(ArrayList<Thing> things) { | |||
| for(Thing tmd : things) { | |||
| Boolean exists = false; | |||
| for(ThingMetaData thisTmd : this.thingMetas) { | |||
| if(tmd.getId() == thisTmd.getId()) { | |||
| for(Thing thisThing : this.things) { | |||
| if(tmd.getId() == thisThing.getId()) { | |||
| exists = true; | |||
| } | |||
| } | |||
| if(!exists) { | |||
| this.thingMetas.add(tmd); | |||
| this.things.add(tmd); | |||
| } | |||
| } | |||
| } | |||
| // helper function for subtractThingMetas | |||
| private static Predicate<ThingMetaData> thingEqual(final ThingMetaData other) | |||
| private static Predicate<Thing> thingEqual(final Thing other) | |||
| { | |||
| return p -> p.getId() == other.getId(); | |||
| } | |||
| /// remove the things in the argument from the current list of things (using their ID) | |||
| public void subtractThingMetas(ArrayList<ThingMetaData> metas) { | |||
| for(ThingMetaData tmd : metas) { | |||
| this.thingMetas.removeIf(thingEqual(tmd)); | |||
| public void subtractThings(ArrayList<Thing> things) { | |||
| for(Thing thing : things) { | |||
| this.things.removeIf(thingEqual(thing)); | |||
| } | |||
| } | |||
| /// keep only things that exist in both argument list and current list (by ID) | |||
| public void intersectThingMetas(ArrayList<ThingMetaData> metas) { | |||
| List<ThingMetaData> cpMetas = new ArrayList<ThingMetaData>(this.thingMetas); | |||
| this.thingMetas.clear(); | |||
| for(ThingMetaData tmd : metas) { | |||
| for(ThingMetaData thisTmd : cpMetas) { | |||
| if(tmd.getId() == thisTmd.getId()) { | |||
| this.thingMetas.add(tmd); | |||
| public void intersectThings(ArrayList<Thing> things) { | |||
| List<Thing> cpThings = new ArrayList<Thing>(this.things); | |||
| this.things.clear(); | |||
| for(Thing thing : things) { | |||
| for(Thing thisThing : cpThings) { | |||
| if(thing.getId() == thisThing.getId()) { | |||
| this.things.add(thing); | |||
| } | |||
| } | |||
| } | |||
| @@ -81,17 +84,8 @@ public class ThingProvider { | |||
| // return the current list of ids | |||
| public List<ThingMetaData> getThingMetas() { | |||
| return thingMetas; | |||
| public List<Thing> getThings() { | |||
| return things; | |||
| } | |||
| // @Inject | |||
| // @Optional | |||
| // private void subscribeTopicTagResult | |||
| // (@UIEventTopic(EventConstants.TOPIC_TAG_RESULT) | |||
| // String empty) { | |||
| // System.out.println("TOPIC_TAG_RESULT: Tag result now."); | |||
| // this.tagResult(); | |||
| // } | |||
| } | |||
| @@ -58,7 +58,6 @@ public class BggUserSourceFilter { | |||
| Label lblUser = new Label(mainCompo, SWT.LEFT); | |||
| lblUser.setText("User name: "); | |||
| lblUser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| // // Define field assists for the text widget | |||
| // // use "." and " " activate the content proposals | |||
| // char[] autoActivationCharacters = new char[] { '.', ' ' }; | |||
| @@ -73,7 +72,9 @@ public class BggUserSourceFilter { | |||
| // } | |||
| cbUserName = new Combo(mainCompo, SWT.DROP_DOWN); | |||
| cbUserName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); | |||
| gd.widthHint = 100; | |||
| cbUserName.setLayoutData(gd); | |||
| cbUserName.setText(configManager.getResultConfig().user); | |||
| cbUserName.addSelectionListener(new SelectionAdapter() { | |||
| public void widgetDefaultSelected(SelectionEvent e) { | |||
| @@ -0,0 +1,6 @@ | |||
| package xyz.veronie.bgg.ui.helpers; | |||
| public class Constants { | |||
| public static final String TMP_PREFIX = "BggToolAnother"; | |||
| public static final String THUMB_CACHE_DIR = "thumbs"; | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| package xyz.veronie.bgg.ui.helpers; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.nio.file.Files; | |||
| import java.nio.file.Path; | |||
| import java.nio.file.Paths; | |||
| import org.eclipse.jface.resource.JFaceResources; | |||
| import org.eclipse.jface.resource.LocalResourceManager; | |||
| public enum Resources { | |||
| INSTANCE; | |||
| private Path prefixPath; | |||
| private Path tmpDir; | |||
| private LocalResourceManager resourceManager; | |||
| private Resources() { | |||
| try { | |||
| if(prefixPath == null) { | |||
| tmpDir = Paths.get(Constants.TMP_PREFIX); | |||
| if(!Files.exists(tmpDir)) { | |||
| Files.createDirectory(tmpDir); | |||
| } | |||
| } else { | |||
| tmpDir = Paths.get(prefixPath + File.separator + Constants.TMP_PREFIX); | |||
| if(!Files.exists(tmpDir)) { | |||
| Files.createDirectory(tmpDir); | |||
| } | |||
| } | |||
| Path thumbPath = getThumbsDir(); | |||
| if(!Files.exists(thumbPath)) { | |||
| Files.createDirectory(thumbPath); | |||
| } | |||
| System.out.println("tmp dir: " + tmpDir.toAbsolutePath()); | |||
| } | |||
| catch(IOException ex) { | |||
| ex.printStackTrace(); | |||
| } | |||
| resourceManager = new LocalResourceManager(JFaceResources.getResources()); | |||
| } | |||
| public Path getThumbsDir() { | |||
| return Paths.get(tmpDir + File.separator + Constants.THUMB_CACHE_DIR); | |||
| } | |||
| public Path getTmpDir() { | |||
| return tmpDir; | |||
| } | |||
| public void dispose() { | |||
| try { | |||
| Files.delete(tmpDir); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| getResourceManager().dispose(); | |||
| } | |||
| public LocalResourceManager getResourceManager() { | |||
| return resourceManager; | |||
| } | |||
| } | |||
| @@ -12,6 +12,7 @@ import org.eclipse.jface.viewers.ColumnLabelProvider; | |||
| import org.eclipse.jface.viewers.TableViewer; | |||
| import org.eclipse.jface.viewers.TableViewerColumn; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.graphics.Image; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| @@ -19,7 +20,7 @@ import org.eclipse.swt.widgets.Label; | |||
| import org.eclipse.swt.widgets.Table; | |||
| import org.eclipse.swt.widgets.TableColumn; | |||
| import xyz.veronie.bgg.result.ThingMetaData; | |||
| import xyz.veronie.bgg.result.Thing; | |||
| import xyz.veronie.bgg.result.ThingProvider; | |||
| import xyz.veronie.bgg.types.EventConstants; | |||
| @@ -61,7 +62,7 @@ public class BggResultPart { | |||
| viewer.setContentProvider(new ArrayContentProvider()); | |||
| // Get the content for the viewer, setInput will call getElements in the | |||
| // contentProvider | |||
| viewer.setInput(thingProvider.getThingMetas()); | |||
| viewer.setInput(thingProvider.getThings()); | |||
| // make the selection available to other views | |||
| // TODO: getSite().setSelectionProvider(viewer); | |||
| // Set the sorter for the table | |||
| @@ -82,19 +83,44 @@ public class BggResultPart { | |||
| // This will create the columns for the table | |||
| private void createColumns(final Composite parent, final TableViewer viewer) { | |||
| String[] titles = ThingMetaData.getTitles(); | |||
| int[] bounds = { 100, 500 }; // , 100, 100, 100, 100 }; | |||
| for(int i = 0; i < titles.length; ++i) { | |||
| TableViewerColumn col = createTableViewerColumn(titles[i], bounds[i], i); | |||
| col.setLabelProvider(new ColumnLabelProvider() { | |||
| @Override | |||
| public String getText(Object element) { | |||
| ThingMetaData t = (ThingMetaData) element; | |||
| return t.getField((int)col.getColumn().getData()); | |||
| } | |||
| }); | |||
| } | |||
| TableViewerColumn col = createTableViewerColumn(Thing.IdHeader, 100, 0); | |||
| col.setLabelProvider(new ColumnLabelProvider() { | |||
| @Override | |||
| public String getText(Object element) { | |||
| Thing t = (Thing) element; | |||
| return t.getField((int)col.getColumn().getData()); | |||
| } | |||
| }); | |||
| TableViewerColumn col2 = createTableViewerColumn(Thing.ThumbHeader, 50, 1); | |||
| col2.setLabelProvider(new ColumnLabelProvider() { | |||
| @Override | |||
| public Image getImage(Object element) { | |||
| Thing t = (Thing) element; | |||
| Image img = t.getThumbnail(); | |||
| if(img != null) { | |||
| return img; | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| @Override | |||
| public String getText(Object element) { | |||
| return ""; | |||
| } | |||
| }); | |||
| TableViewerColumn col3 = createTableViewerColumn(Thing.NameHeader, 400, 2); | |||
| col3.setLabelProvider(new ColumnLabelProvider() { | |||
| @Override | |||
| public String getText(Object element) { | |||
| Thing t = (Thing) element; | |||
| return t.getField((int)col3.getColumn().getData()); | |||
| } | |||
| }); | |||
| } | |||
| private TableViewerColumn createTableViewerColumn(String title, int bound, final int colNumber) { | |||
| @@ -124,11 +150,10 @@ public class BggResultPart { | |||
| (@UIEventTopic(EventConstants.TOPIC_RESULT_CHANGED) | |||
| String empty) { | |||
| System.out.println("TOPIC_RESULT_CHANGED"); | |||
| List<ThingMetaData> thingMetas = thingProvider.getThingMetas(); | |||
| viewer.setInput(thingMetas); | |||
| viewer.refresh(); | |||
| statsLabel.setText(Integer.toString(thingMetas.size()) + " items"); | |||
| List<Thing> things = thingProvider.getThings(); | |||
| viewer.setInput(things); | |||
| viewer.refresh(true); | |||
| statsLabel.setText(Integer.toString(things.size()) + " items"); | |||
| statsLabel.redraw(); | |||
| } | |||
| @@ -30,7 +30,7 @@ import org.eclipse.swt.widgets.Label; | |||
| import xyz.veronie.bgg.result.BggApi; | |||
| import xyz.veronie.bgg.result.ResultConfig; | |||
| import xyz.veronie.bgg.result.ResultConfigManager; | |||
| import xyz.veronie.bgg.result.ThingMetaData; | |||
| import xyz.veronie.bgg.result.Thing; | |||
| import xyz.veronie.bgg.result.ThingProvider; | |||
| import xyz.veronie.bgg.types.EventConstants; | |||
| import xyz.veronie.bgg.types.ResultAction; | |||
| @@ -156,8 +156,8 @@ public class PreparePart { | |||
| } else { | |||
| eventBroker.send(EventConstants.TOPIC_STATUS, "Fetching " + selection.getFirstElement().toString() + " '" + user + "'..."); | |||
| try { | |||
| ArrayList<ThingMetaData> thingMetas = bggApi.getThingsForUser(user); | |||
| useThingsOnResult(thingMetas); | |||
| ArrayList<Thing> things = bggApi.getThingsForUser(user); | |||
| useThingsOnResult(things); | |||
| } | |||
| catch(IllegalArgumentException ex) { | |||
| MessageDialog.openError(mainComposite.getShell(), "", ex.getMessage()); | |||
| @@ -172,8 +172,8 @@ public class PreparePart { | |||
| } else { | |||
| eventBroker.send(EventConstants.TOPIC_STATUS, "Fetching for geeklist id '" + geeklistId + "'"); | |||
| try { | |||
| ArrayList<ThingMetaData> thingMetas = bggApi.getThingsForGeeklist(geeklistId); | |||
| useThingsOnResult(thingMetas); | |||
| ArrayList<Thing> things = bggApi.getThingsForGeeklist(geeklistId); | |||
| useThingsOnResult(things); | |||
| } | |||
| catch(IllegalArgumentException ex) { | |||
| MessageDialog.openError(mainComposite.getShell(), "", ex.getMessage()); | |||
| @@ -187,8 +187,8 @@ public class PreparePart { | |||
| } else { | |||
| eventBroker.send(EventConstants.TOPIC_STATUS, "Fetching for family id '" + familyId + "'"); | |||
| try { | |||
| ArrayList<ThingMetaData> thingMetas = bggApi.getThingsForFamily(familyId); | |||
| useThingsOnResult(thingMetas); | |||
| ArrayList<Thing> things = bggApi.getThingsForFamily(familyId); | |||
| useThingsOnResult(things); | |||
| } | |||
| catch(IllegalArgumentException ex) { | |||
| MessageDialog.openError(mainComposite.getShell(), "", ex.getMessage()); | |||
| @@ -197,23 +197,23 @@ public class PreparePart { | |||
| } | |||
| } | |||
| private void useThingsOnResult(ArrayList<ThingMetaData> thingMetas) { | |||
| private void useThingsOnResult(ArrayList<Thing> things) { | |||
| switch(configManager.getResultConfig().action) { | |||
| case REP: | |||
| thingProvider.replaceThingMetas(thingMetas); | |||
| thingProvider.replaceThings(things); | |||
| break; | |||
| case ADD: | |||
| thingProvider.addThingMetas(thingMetas); | |||
| thingProvider.addThings(things); | |||
| break; | |||
| case SUB: | |||
| thingProvider.subtractThingMetas(thingMetas); | |||
| thingProvider.subtractThings(things); | |||
| break; | |||
| case AND: | |||
| thingProvider.intersectThingMetas(thingMetas); | |||
| thingProvider.intersectThings(things); | |||
| break; | |||
| } | |||
| eventBroker.send(EventConstants.TOPIC_RESULT_CHANGED, ""); | |||
| eventBroker.send(EventConstants.TOPIC_STATUS, "Fetched " + Integer.toString(thingMetas.size()) + " things."); | |||
| eventBroker.send(EventConstants.TOPIC_STATUS, "Fetched " + Integer.toString(things.size()) + " things."); | |||
| } | |||
| }); | |||