Browse Source

Tagging for results (in progress) - Added maven to get gson dependency.

pull/2/head
veronie 5 years ago
parent
commit
17f9e9ad8f
17 changed files with 350 additions and 77 deletions
  1. +2
    -1
      xyz.veronie.bgg.ui/META-INF/MANIFEST.MF
  2. +80
    -0
      xyz.veronie.bgg.ui/pom.xml
  3. +5
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggApi.java
  4. +2
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ResultConfig.java
  5. +10
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ResultConfigManager.java
  6. +11
    -21
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingMetaData.java
  7. +58
    -4
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java
  8. +5
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/EventConstants.java
  9. +26
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/FamilyType.java
  10. +42
    -8
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java
  11. +33
    -1
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java
  12. +19
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/helpers/CommonControls.java
  13. +30
    -4
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java
  14. +5
    -33
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java
  15. +17
    -0
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadThingDetailsPart.java
  16. +1
    -5
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/StatusBar.java
  17. +4
    -0
      xyz.veronie.bgg.ui/target/maven-archiver/pom.properties

+ 2
- 1
xyz.veronie.bgg.ui/META-INF/MANIFEST.MF View File

@@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.core.runtime,
javax.inject
Automatic-Module-Name: de.wt.secondtry
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.inject;version="1.0.0",
Import-Package: com.google.gson;version="2.8.2",
javax.inject;version="1.0.0",
org.eclipse.e4.ui.model.application.descriptor.basic,
org.eclipse.e4.ui.model.application.ui.basic

+ 80
- 0
xyz.veronie.bgg.ui/pom.xml View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.veronie.bgg</groupId>
<artifactId>xyz.veronie.bgg.ui</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>xyz.veronie.bgg.ui2</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

+ 5
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggApi.java View File

@@ -28,6 +28,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import xyz.veronie.bgg.types.EventConstants;
import xyz.veronie.bgg.types.FamilyType;
import xyz.veronie.bgg.types.FilterFlagState;
import xyz.veronie.bgg.types.Subtype;
import xyz.veronie.bgg.types.UserFlag;
@@ -99,6 +100,10 @@ public class BggApi {
StringBuilder urlStr = new StringBuilder();
urlStr.append(BASE_URL + FAMILY + "?id=" + String.valueOf(resultConfig.familyId));
if(resultConfig.familyType != FamilyType.ALL) {
urlStr.append("?type=" + resultConfig.familyType);
}
return getThings(urlStr.toString());
}


+ 2
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ResultConfig.java View File

@@ -2,6 +2,7 @@ package xyz.veronie.bgg.result;
import java.util.HashMap;
import xyz.veronie.bgg.types.FamilyType;
import xyz.veronie.bgg.types.FilterFlagState;
import xyz.veronie.bgg.types.ResultAction;
import xyz.veronie.bgg.types.SourceFilter;
@@ -32,6 +33,7 @@ public class ResultConfig {
public Integer geeklistId = null;
public Integer familyId = null;
public FamilyType familyType = FamilyType.ALL;
// TODO: add others


+ 10
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ResultConfigManager.java View File

@@ -9,6 +9,7 @@ import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.UIEventTopic;
import xyz.veronie.bgg.types.EventConstants;
import xyz.veronie.bgg.types.FamilyType;
import xyz.veronie.bgg.types.ResultAction;
import xyz.veronie.bgg.types.SourceFilter;
import xyz.veronie.bgg.types.Subtype;
@@ -94,6 +95,15 @@ public class ResultConfigManager {
System.out.println("TOPIC_FAMILY_CHANGED: geeklistId = " + id);
}
@Inject
@Optional
private void subscribeTopicResultFamilyChanged
(@UIEventTopic(EventConstants.TOPIC_FAMILYTYPE_CHANGED)
FamilyType ft) {
getResultConfig().familyType = ft;
System.out.println("TOPIC_FAMILYTYPE_CHANGED: family type = " + ft);
}
public ResultConfig getResultConfig() {
return resultConfig;
}


+ 11
- 21
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingMetaData.java View File

@@ -2,9 +2,11 @@ package xyz.veronie.bgg.result;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import com.google.gson.Gson;
public class ThingMetaData {
public class ThingMetaData implements java.io.Serializable {
private static final long serialVersionUID = -5268898737006538509L;
private int id;
private String name;
private String imgURL;
@@ -12,7 +14,7 @@ public class ThingMetaData {
private String comment;
private Integer numPlays;
private static String[] titles = { "Id", "Name" }; //, "Image", "Thumb", "comment", "# plays"};
private static String[] titles = { "Id", "Name" };
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
@@ -55,25 +57,9 @@ public class ThingMetaData {
case 1:
returnStr = this.name;
break;
// case 2:
// returnStr = this.imgURL;
// break;
// case 3:
// returnStr = this.thumbURL;
// break;
// case 4:
// returnStr = this.comment;
// break;
// case 5:
// if (this.numPlays == null) {
// returnStr = "";
// } else {
// returnStr = String.valueOf(this.numPlays);
// }
// break;
default:
throw new ArrayIndexOutOfBoundsException(
"idx " + String.valueOf(idx) + " must be in [0," + (titles.length-1) + "]");
"idx " + String.valueOf(idx) + " must be in [0,1]");
}
return returnStr;
@@ -137,8 +123,12 @@ public class ThingMetaData {
@Override
public String toString() {
return String.valueOf(id);
//return String.valueOf(id);
Gson gson = new Gson();
return gson.toJson(this);
}
}

+ 58
- 4
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java View File

@@ -1,40 +1,67 @@
package xyz.veronie.bgg.result;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.UIEventTopic;
import com.google.gson.Gson;
import xyz.veronie.bgg.types.EventConstants;
import xyz.veronie.bgg.types.SourceFilter;
public enum ThingProvider {
INSTANCE;
/// list of things. Each ID is expected to exist exactly once.
private List<ThingMetaData> thingMetas;
private ThingProvider() {
thingMetas = new ArrayList<ThingMetaData>();
}
/// replace current list with new list
public void replaceThingMetas(ArrayList<ThingMetaData> metas) {
this.thingMetas = metas;
}
/// add things from argument to current list iff their ID does not exist yet
public void addThingMetas(ArrayList<ThingMetaData> metas) {
this.thingMetas.addAll(metas);
for(ThingMetaData tmd : metas) {
Boolean exists = false;
for(ThingMetaData thisTmd : this.thingMetas) {
if(tmd.getId() == thisTmd.getId()) {
exists = true;
}
}
if(!exists) {
this.thingMetas.add(tmd);
}
}
}
public static Predicate<ThingMetaData> thingEqual(ThingMetaData other)
// helper functino for subtractThingMetas
private static Predicate<ThingMetaData> thingEqual(ThingMetaData 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));
}
}
/// 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();
@@ -47,8 +74,35 @@ public enum ThingProvider {
}
}
/// create a tag of the current list
public void tagResult() {
Gson gson = new Gson();
String resultList = gson.toJson(this.thingMetas);
try {
BufferedWriter writer = new BufferedWriter(
new FileWriter("result_" + Long.toString(System.currentTimeMillis())));
writer.write(resultList);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// return the current list of ids
public List<ThingMetaData> getThingMetas() {
return thingMetas;
}
@Inject
@Optional
private void subscribeTopicSourceChanged
(@UIEventTopic(EventConstants.TOPIC_TAG_RESULT)
String str) {
System.out.println("Tag result now.");
this.tagResult();
}
}

+ 5
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/EventConstants.java View File

@@ -18,6 +18,8 @@ public interface EventConstants {
String TOPIC_FAMILY_CHANGED = "CONFIG_CHANGED/FAMILY";
String TOPIC_FAMILYTYPE_CHANGED = "CONFIG_CHANGED/FAMILYTYPE";
String TOPIC_RESULT_CHANGED = "RESULT_CHANGED";
String TOPIC_STATUS = "STATUS";
@@ -26,4 +28,7 @@ public interface EventConstants {
String TOPIC_FAMILY_INFO = "INFO/FAMILY";
String TOPIC_TAG_RESULT = "EVENT_TAG_RESULT";
}

+ 26
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/types/FamilyType.java View File

@@ -0,0 +1,26 @@
package xyz.veronie.bgg.types;
public enum FamilyType {
ALL("any", ""),
BG_FAMILY("board game family", "boardgamefamily"),
RPG("RPG", "rpg"),
RPG_PERIODIC("RPG periodical", "rpgperiodical");
private String name; //< the display name
private String familyApiString; //< the THINGTYPE string for BGG XMLAPI2
private FamilyType(String name, String familyApiString) {
this.name = name;
this.familyApiString = familyApiString;
}
@Override
public String toString() {
return this.name;
}
/// return the string used in BGG XMLAPI2 to identify the thingtype
public String toApiString() {
return this.familyApiString;
}
}

+ 42
- 8
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java View File

@@ -1,5 +1,6 @@
package xyz.veronie.bgg.ui.filters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -28,8 +29,10 @@ import org.eclipse.swt.widgets.Label;
import xyz.veronie.bgg.result.ResultConfigManager;
import xyz.veronie.bgg.types.EventConstants;
import xyz.veronie.bgg.types.FilterFlagState;
import xyz.veronie.bgg.types.Subtype;
import xyz.veronie.bgg.types.UserFlag;
import xyz.veronie.bgg.types.UserFlagEvent;
import xyz.veronie.bgg.ui.helpers.CommonControls;
@@ -46,7 +49,7 @@ public class BggUserSourceFilter {
public void create(Composite parent, int style) {
GridLayout filterLayout = new GridLayout(4, false);
GridLayout filterLayout = new GridLayout(5, false);
parent.setLayout(filterLayout);
Label lblUser = new Label(parent, SWT.LEFT);
@@ -87,36 +90,67 @@ public class BggUserSourceFilter {
}
});
Button btEditUsers = new Button(parent, SWT.PUSH);
btEditUsers.setText("edit users");
btEditUsers.setEnabled(false);
btEditUsers.setVisible(false);
btEditUsers.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
// Button btEditUsers = new Button(parent, SWT.PUSH);
// btEditUsers.setText("edit users");
// btEditUsers.setEnabled(false);
// btEditUsers.setVisible(false);
// btEditUsers.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
// TODO: implement edit users
CommonControls.makeEmptySpace(parent, 1);
// choose the thing sub-type
Label lblSubtype = new Label(parent, SWT.LEFT);
lblSubtype.setText("Subtypes: ");
lblSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
ComboViewer cbSubtypes = new ComboViewer(parent, SWT.READ_ONLY);
cbSubtypes.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
cbSubtypes.setContentProvider(ArrayContentProvider.getInstance());
List<Subtype> subtypes = new ArrayList<Subtype>();
for (Subtype st : Subtype.values()) {
subtypes.add(st);
}
cbSubtypes.setInput(subtypes);
cbSubtypes.setSelection(new StructuredSelection(configManager.getResultConfig().subtype));
cbSubtypes.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
eventBroker.send(EventConstants.TOPIC_SUBTYPE_CHANGED, selection.getFirstElement());
}
});
Label infoLabel = new Label(parent, SWT.LEFT);
infoLabel.setText("Select which flags are used as filter. Filters follow 'AND' rule.");
GridData gdInfo = new GridData(SWT.FILL, SWT.FILL, true, false);
gdInfo.horizontalSpan = 4;
gdInfo.horizontalSpan = 5;
infoLabel.setLayoutData(gdInfo);
makeFilter(parent, UserFlag.OWN);
makeFilter(parent, UserFlag.WTP);
CommonControls.makeEmptySpace(parent, 1);
makeFilter(parent, UserFlag.PREVIOUSLY_OWNED);
makeFilter(parent, UserFlag.WTB);
CommonControls.makeEmptySpace(parent, 1);
makeFilter(parent, UserFlag.TRADE);
makeFilter(parent, UserFlag.WISHLIST);
CommonControls.makeEmptySpace(parent, 1);
makeFilter(parent, UserFlag.WANT);
makeFilter(parent, UserFlag.PREORDERED);
CommonControls.makeEmptySpace(parent, 1);
makeFilter(parent, UserFlag.RATED);
makeFilter(parent, UserFlag.COMMENT);
CommonControls.makeEmptySpace(parent, 1);
makeFilter(parent, UserFlag.PLAYED);
parent.pack();
parent.getParent().pack();
parent.layout();


+ 33
- 1
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java View File

@@ -1,5 +1,8 @@
package xyz.veronie.bgg.ui.filters;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Creatable;
@@ -7,6 +10,12 @@ import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.FocusEvent;
@@ -21,6 +30,7 @@ import org.eclipse.swt.widgets.Label;
import xyz.veronie.bgg.result.ResultConfigManager;
import xyz.veronie.bgg.types.EventConstants;
import xyz.veronie.bgg.types.FamilyType;
/// These are the controls to retrieve thing IDs for a given family ID
@Creatable
@@ -45,7 +55,7 @@ public class FamilySourceFilter {
if(fid != null) {
cbFamilyId.setText(Integer.toString(fid));
}
cbFamilyId.addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
try {
@@ -78,6 +88,28 @@ public class FamilySourceFilter {
}
});
Label lblFamilyType = new Label(parent, SWT.LEFT);
lblFamilyType.setText("Family Type: ");
lblFamilyType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
ComboViewer cbSubtypes = new ComboViewer(parent, SWT.READ_ONLY);
cbSubtypes.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
cbSubtypes.setContentProvider(ArrayContentProvider.getInstance());
List<FamilyType> subtypes = new ArrayList<FamilyType>();
for (FamilyType ft : FamilyType.values()) {
subtypes.add(ft);
}
cbSubtypes.setInput(subtypes);
cbSubtypes.setSelection(new StructuredSelection(configManager.getResultConfig().familyType));
cbSubtypes.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
eventBroker.send(EventConstants.TOPIC_FAMILYTYPE_CHANGED, selection.getFirstElement());
}
});
confLabel = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY);
confLabel.setText("");
confLabel.setWordWrap(true);


+ 19
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/helpers/CommonControls.java View File

@@ -0,0 +1,19 @@
package xyz.veronie.bgg.ui.helpers;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
public class CommonControls {
public static void makeEmptySpace(Composite parent, int span) {
Label empty = new Label(parent, SWT.LEFT);
empty.setText("");
GridData gde = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
if(span > 1) {
gde.horizontalSpan = span;
}
empty.setLayoutData(gde);
}
}

+ 30
- 4
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java View File

@@ -1,9 +1,12 @@
package xyz.veronie.bgg.ui.parts;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -12,7 +15,9 @@ import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -22,20 +27,35 @@ import xyz.veronie.bgg.types.EventConstants;
public class BggResultPart {
private TableViewer viewer;
private Label statsLabel;
@Inject private IEventBroker eventBroker;
@PostConstruct
public void createControls(Composite parent) {
Composite main = new Composite(parent, SWT.FILL);
GridLayout layout = new GridLayout(1, false);
main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
GridLayout layout = new GridLayout(2, false);
main.setLayout(layout);
createViewer(main);
statsLabel = new Label(main, SWT.FILL);
statsLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
statsLabel.setText("0 items");
Button tagResultButton = new Button(main, SWT.PUSH);
tagResultButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
tagResultButton.addListener(SWT.SELECTED, event -> {
eventBroker.post(EventConstants.TOPIC_TAG_RESULT, "");
});
}
private void createViewer(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER );
createColumns(parent, viewer);
final Table table = viewer.getTable();
table.setHeaderVisible(true);
@@ -52,10 +72,10 @@ public class BggResultPart {
// Layout the viewer
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 2;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.horizontalSpan = 2;
viewer.getControl().setLayoutData(gridData);
}
@@ -107,8 +127,14 @@ public class BggResultPart {
(@UIEventTopic(EventConstants.TOPIC_RESULT_CHANGED)
String empty) {
System.out.println("TOPIC_RESULT_CHANGED");
viewer.setInput(ThingProvider.INSTANCE.getThingMetas());
List<ThingMetaData> thingMetas = ThingProvider.INSTANCE.getThingMetas();
viewer.setInput(thingMetas);
viewer.refresh();
statsLabel.setText(Integer.toString(thingMetas.size()) + " items");
statsLabel.redraw();
}
}

+ 5
- 33
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java View File

@@ -42,6 +42,7 @@ import xyz.veronie.bgg.ui.filters.GeeklistSourceFilter;
import xyz.veronie.bgg.ui.filters.RankSourceFilter;
import xyz.veronie.bgg.ui.filters.SearchSourceFilter;
import xyz.veronie.bgg.ui.filters.YearSourceFilter;
import xyz.veronie.bgg.ui.helpers.CommonControls;
@@ -98,29 +99,9 @@ public class LoadFromBggPart {
cbSource.setSelection(new StructuredSelection(configManager.getResultConfig().source));
// listener is configured further below
makeEmptySpace(main, 1);
CommonControls.makeEmptySpace(main, 3);
// choose the thing sub-type
Label lblSubtype = new Label(main, SWT.LEFT);
lblSubtype.setText("Subtypes: ");
lblSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
ComboViewer cbSubtypes = new ComboViewer(main, SWT.READ_ONLY);
cbSubtypes.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
cbSubtypes.setContentProvider(ArrayContentProvider.getInstance());
List<Subtype> subtypes = new ArrayList<Subtype>();
for (Subtype st : Subtype.values()) {
subtypes.add(st);
}
cbSubtypes.setInput(subtypes);
cbSubtypes.setSelection(new StructuredSelection(configManager.getResultConfig().subtype));
cbSubtypes.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
eventBroker.send(EventConstants.TOPIC_SUBTYPE_CHANGED, selection.getFirstElement());
}
});
@@ -147,7 +128,7 @@ public class LoadFromBggPart {
// next row:
makeEmptySpace(main, 5);
CommonControls.makeEmptySpace(main, 5);
// next row
@@ -242,7 +223,7 @@ public class LoadFromBggPart {
ComboViewer cbAct = new ComboViewer(main, SWT.READ_ONLY);
GridData gdact = new GridData(SWT.FILL, SWT.FILL, false, false);
cbSubtypes.getCombo().setLayoutData(gdact);
cbAct.getCombo().setLayoutData(gdact);
cbAct.setContentProvider(ArrayContentProvider.getInstance());
List<ResultAction> actions = new ArrayList<ResultAction>();
for(ResultAction act : ResultAction.values()) {
@@ -331,14 +312,5 @@ public class LoadFromBggPart {
}
public void makeEmptySpace(Composite parent, int span) {
Label empty = new Label(parent, SWT.LEFT);
empty.setText("");
GridData gde = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
if(span > 1) {
gde.horizontalSpan = span;
}
empty.setLayoutData(gde);
}
}

+ 17
- 0
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadThingDetailsPart.java View File

@@ -1,5 +1,22 @@
package xyz.veronie.bgg.ui.parts;
import javax.annotation.PostConstruct;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
public class LoadThingDetailsPart {
@PostConstruct
public void createControls(Composite parent) {
Composite main = new Composite(parent, SWT.FILL);
main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
GridLayout layout = new GridLayout(5, false);
main.setLayout(layout);
}
}

+ 1
- 5
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/StatusBar.java View File

@@ -7,16 +7,11 @@ import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.resource.ColorDescriptor;
import org.eclipse.jface.resource.DeviceResourceException;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -38,6 +33,7 @@ public class StatusBar {
statusLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// create the manager and bind to a widget
// TODO: do I have to free the color? how?
ResourceManager resManager =
new LocalResourceManager(JFaceResources.getResources(), statusLabel);
statusLabel.setBackground(resManager.createColor(new RGB(255,255,0)));


+ 4
- 0
xyz.veronie.bgg.ui/target/maven-archiver/pom.properties View File

@@ -0,0 +1,4 @@
#Created by Apache Maven 3.6.3
version=0.0.1-SNAPSHOT
groupId=xyz.veronie.bgg
artifactId=xyz.veronie.bgg.ui

Loading…
Cancel
Save