From 79417998049a581830b6b11b6d9edecadfa08d8d Mon Sep 17 00:00:00 2001 From: veronie Date: Sun, 24 May 2020 16:11:53 +0200 Subject: [PATCH] Improved layout, added Download controls, tried to make this a maven project to use gson (no success) --- xyz.veronie.bgg.ui/.classpath | 13 +- xyz.veronie.bgg.ui/.gitignore | 1 + xyz.veronie.bgg.ui/.project | 6 + xyz.veronie.bgg.ui/Application.e4xmi | 27 ++- xyz.veronie.bgg.ui/META-INF/MANIFEST.MF | 6 +- xyz.veronie.bgg.ui/build.properties | 1 + xyz.veronie.bgg.ui/icons/download-button.png | Bin 0 -> 1584 bytes xyz.veronie.bgg.ui/icons/save-button.png | Bin 0 -> 1993 bytes .../icons/save-button_20x20.png | Bin 0 -> 3599 bytes xyz.veronie.bgg.ui/pom.xml | 12 +- .../src/xyz/veronie/bgg/result/BggFamily.java | 5 - .../xyz/veronie/bgg/result/ThingProvider.java | 34 ++- .../bgg/ui/filters/BggUserSourceFilter.java | 70 +++--- .../bgg/ui/filters/FamilySourceFilter.java | 8 +- .../bgg/ui/filters/GeeklistSourceFilter.java | 8 +- .../bgg/ui/handlers/HandleSaveGamelist.java | 23 ++ .../veronie/bgg/ui/parts/BggResultPart.java | 14 +- .../ui/parts/DownloadThingDetailsPart.java | 225 ++++++++++++++++++ .../bgg/ui/parts/LoadThingDetailsPart.java | 22 -- ...{LoadFromBggPart.java => PreparePart.java} | 87 +++---- .../xyz/veronie/bgg/ui/parts/StatusBar.java | 3 +- .../ui/result/DownloadProgressMonitor.java | 14 ++ 22 files changed, 418 insertions(+), 161 deletions(-) create mode 100644 xyz.veronie.bgg.ui/.gitignore create mode 100644 xyz.veronie.bgg.ui/icons/download-button.png create mode 100644 xyz.veronie.bgg.ui/icons/save-button.png create mode 100644 xyz.veronie.bgg.ui/icons/save-button_20x20.png delete mode 100644 xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggFamily.java create mode 100644 xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleSaveGamelist.java create mode 100644 xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/DownloadThingDetailsPart.java delete mode 100644 xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadThingDetailsPart.java rename xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/{LoadFromBggPart.java => PreparePart.java} (80%) create mode 100644 xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/result/DownloadProgressMonitor.java diff --git a/xyz.veronie.bgg.ui/.classpath b/xyz.veronie.bgg.ui/.classpath index b862a29..1bc46b2 100644 --- a/xyz.veronie.bgg.ui/.classpath +++ b/xyz.veronie.bgg.ui/.classpath @@ -1,7 +1,16 @@ - + + + + + - + + + + + + diff --git a/xyz.veronie.bgg.ui/.gitignore b/xyz.veronie.bgg.ui/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/xyz.veronie.bgg.ui/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/xyz.veronie.bgg.ui/.project b/xyz.veronie.bgg.ui/.project index c10fca4..fcc9de6 100644 --- a/xyz.veronie.bgg.ui/.project +++ b/xyz.veronie.bgg.ui/.project @@ -20,8 +20,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/xyz.veronie.bgg.ui/Application.e4xmi b/xyz.veronie.bgg.ui/Application.e4xmi index aa8f4a9..d296003 100644 --- a/xyz.veronie.bgg.ui/Application.e4xmi +++ b/xyz.veronie.bgg.ui/Application.e4xmi @@ -1,17 +1,25 @@ - + - - - - + + + + + + + + + + - - - + + + + + @@ -21,6 +29,9 @@ + + + diff --git a/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF b/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF index a8c27b6..e18a3d4 100644 --- a/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF +++ b/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF @@ -13,10 +13,10 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.jface, org.eclipse.e4.core.services, org.eclipse.osgi.services, - javax.inject + javax.inject, + org.eclipse.e4.ui.model.workbench Automatic-Module-Name: de.wt.secondtry Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: com.google.gson;version="2.8.2", - javax.inject;version="1.0.0", +Import-Package: javax.inject;version="1.0.0", org.eclipse.e4.ui.model.application.descriptor.basic, org.eclipse.e4.ui.model.application.ui.basic diff --git a/xyz.veronie.bgg.ui/build.properties b/xyz.veronie.bgg.ui/build.properties index 14919a9..f8a7909 100644 --- a/xyz.veronie.bgg.ui/build.properties +++ b/xyz.veronie.bgg.ui/build.properties @@ -1,5 +1,6 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ + plugin.xml,\ Application.e4xmi source.. = src/ diff --git a/xyz.veronie.bgg.ui/icons/download-button.png b/xyz.veronie.bgg.ui/icons/download-button.png new file mode 100644 index 0000000000000000000000000000000000000000..33b99d518b22be7ba8822485e88606cf37f1a4a8 GIT binary patch literal 1584 zcmds1{ZCV86n@|L9zI$`T2QG}li8AcNa)N}&)XwPeO!rm(0Buu2BOESxf@ z=n|YCb2TP-$6R)G2_tNYM5pN{l1ofF-3&3ZE!TZu=c+R-+Zx$)^&jx3{j?`J=RD^l z&u`~B*x+@gYjd=OkaTyoeG?%pK^XxqQIdU=lZnFZvAP>mQ&Xq!)T@bB(^1{DhY(%U z)1Wt6PM8zJ#hng+=jQg-&aUP_3+d|WD&E<)d(Zafj+Wx~z$>R7ROBR%@*8R!9Z#M- zNziBDyN(@O5^HVeChumld|jzf?LTn+N1=D?AwrUNyX}_7?%VfoUOSTO(CxpWw?F3} zZ7IxJXD!yf`dZ(mt=AW2l=_y9dk$}0fBs_8$0eUe+AUYJ3xB=S9N$*8|Ni*{+AM)k z(EVQ%8s{Fo_xs$2;_z?TgMZ94;FjKsvgrePhxPHZFXCS*?UFJ00lBU3?u{E`4%LjU zFu+9}>OAy8ghcJ?5_Cd@Ms4b9EQ1J(TGa|%2@x)8QMI@ThDlUVb1)f(sa&s`a2AG{ z>{ZM02N>q$IuY<|a1yyzoQGe+1d%=B0vrV=m21Q$I0O?^c8kmLC^(s1Ew08sm|(I? zEX4pgIoT;z;L9+<$qt?gtC*gc^!>DyjjG&`cbu<5afrnSzELAtqga zQUeOB@oyNSX9{)c{KjB6nbeGPN}ZUDH=&g%wc>mnhZ&-H#6|cSv{I!;T#9F4hAM7x zB_4-Xrc{f?xDRHS;u6cS6IwaNDOTbRnBf$Mn1qesBZ^&2M>|Xr#U?JqQt(m5D(2#H zn4*eBT!9O~#}q+ag8);^UoURJpTWoZ>%F=zv+`xA9rH0!pag!e?U=1Zb$9H{vfaN<(#g9!|n64SDziJPRc(11#>V)hBQB==xX^Y^s|LzU#3j> zqe40f!Yq{8tSB__yydf z29LB1-v<*jxTTetkYNUwWWr`R#|#ds7%gy*8EjGs=7WhdSfnyc=x}3RsT{AtIc}^* zs>HY99yjKcIP^d{8M8_$mTrZ{JH*kTNJyHf9gGa>dlCp3!lvA@!%Em0{p=PgS z#4B)tnroyyd=nl~vr{TS8<#*@TUv{Ash!Ck*}({T zkbm76&V?SX`=roC)@DZMt1H+)^m9R~!n>LnQJdIC(mfDfN(S>sQt%^9jHzyRk#rvl zSCT<~Bm<}6b=Gk#>?LjbTWR5RwwK0FgxkpF{1GF5qKT!bMQo17kA?@xWqzapztY4s z>Uy@9#ZQNa$>V~NBJ9<~($qXQ$Kt2L5mKqYwK)6|{F(glNcekFnR#moo_q$H9$xO9 nZmY`EKD@I1;-&w}+i;3LhSLM)!Mol~<4?WX?eN-%tzzH54-d@P literal 0 HcmV?d00001 diff --git a/xyz.veronie.bgg.ui/icons/save-button.png b/xyz.veronie.bgg.ui/icons/save-button.png new file mode 100644 index 0000000000000000000000000000000000000000..1e21dfa8fba302d8bb2423fd0e7ccb740271081c GIT binary patch literal 1993 zcmeHI=U3AQ6#WGVgc(+Zve6ij8J2*SO$Zo>VIyGK5E*5JKmY{{L!hz|1of~alv%VE zgQ!FrR+%!&3d&&>iELzuF^wPk5A?I|ocrE+_niCXo^#*J#$nOI0x|*s00`UJT03#3 z=r=&PIbBr~>I?wf28k{nu}*&RN>MS9!8gK#lwuR2f|PXl)?Tz zM+3y4PLIJWxXxOXR&wVig^vd65^gy+JZ^3HxebTeJ4tP4rhGAFL>}WV5*#O;umj5y zgduMvG9`KMMR7j!b=UFy;+w5j{>%$i(0|-D=euZHkx)j=*e*W4J!B@X%4P7YQyj9lv#$kWy)uWMeQ&dMjTLqPH!X{RUiGB3i18|73vOzBEjreU zrm8LV@iU*}wowYTv(l_D#PbN%io=|}Ey~DE-aI}yl=&o`Lgfj#u31~I{hBLbe@YR5 zPgmzxA#|Y(OlH#Er=f=4{|IJ6SZxbGQ=&JGH13(jw`IzCB593`>k#C=t6|N zeg>q~9%4gU(SC3mzIS;z*RkGuWpiABxa&Qw8c_5go&Ss&H3#?FfX*#%xWA+YEUe^aG+LXg|pbv)pLJ7LK3K?)#- zk^?&FbnGl?tyk~LU|EL5RlN~JYC!>+>>vVe^OtN^%*`}#f!j(J!qwK`7(3-2_=WQh z`vvMU`i*!e*NNsHGD-qN2`+63907$?t&|vejdV!HfwKktVaHM)BBtG9P~-9HJMt&0 zu)+FXH3QccH-cua7v2cr89LXz>UOCkuehd9%Y?Z3H$j^_EFxX(&RzZ3nf_Yu$%|9* zo3fL5=Vesr=MN}hxB5gui+!WQ0U^4Pcoq|$3LY*lH_Rzi=@=La>7|I;6za}WZHlEu zd$Ag6T5*vpuj#|tx3Xo~^2Ua5Swb-)>+cAssh$tEJ6>cx>Wm8A;Eq#V>xA{WtzlYT z&ZTIM83m7{i%k+cDxF8CxfZ7Oz5C{ylj=%N+qTdFKQ^uX)U@0=X<8l6TnHn6!5pW6 zKf~55g$~;M82J%dN3W7tfN|21r~G@f8B=5P*0jxgm%cK8t7ThM-DbEQ zk~9DSrQfi!!r56_{TCokY#!b!G_n2DT&~B*3xo2^nW@gQ%G?OFaG^UkdhiI=wTv~U z4b=IJJyy1hj+XQm6iL=_llOi|Bu2q_-atiF&?+dY3%eOQOY%q32TZ+e#qh5BqS{W!>CRGx!N3GpIjRzs68X$nizRd`Mx-lRYyRVExtK{=xk{d>;HpAt;(gcH3{r&= zLS1b&XayY?H{O4onI3L z@3Y{qW~cno<|J7vbt`mSA*zGhx>Da!Dq;XV;iU%J4mofD`>vmn_8=rOKQ14D`W@W| z4QX$bk#3Za#IpFKqr=1Pa%_s3m2XT5>vjbV0JyAh_AaQII3G5f&AD>l>$?O0&w)8) z4V9w=#X4b~0rRyP&OZb|{us11kOh{v0E2 z;&LRvm!}*`%g)-uMS3E@*VmFu$ecz`M{tP+rw;f*kbV;8dKuxM^k1SNzMdGIV9wFl YF)+Xj$~CikvByyYb||cMtEDgbUm7uoSpWb4 literal 0 HcmV?d00001 diff --git a/xyz.veronie.bgg.ui/icons/save-button_20x20.png b/xyz.veronie.bgg.ui/icons/save-button_20x20.png new file mode 100644 index 0000000000000000000000000000000000000000..1a9b96ee1cdd9db796fa9080d822a1f4e8c4658e GIT binary patch literal 3599 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.veronie.bgg.ui 0.0.1-SNAPSHOT - xyz.veronie.bgg.ui2 + xyz.veronie.bgg.ui http://www.example.com @@ -19,17 +19,17 @@ - - com.google.code.gson - gson - 2.8.6 - junit junit 4.11 test + + com.google.code.gson + gson + 2.8.6 + diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggFamily.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggFamily.java deleted file mode 100644 index abda4f5..0000000 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggFamily.java +++ /dev/null @@ -1,5 +0,0 @@ -package xyz.veronie.bgg.result; - -public class BggFamily { - -} 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 f9c1a61..78a71dd 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 @@ -6,17 +6,12 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; +import xyz.veronie.bgg.result.ThingMetaData; -import javax.inject.Inject; - -import org.eclipse.e4.core.di.annotations.Optional; -import org.eclipse.e4.ui.di.UIEventTopic; +import org.eclipse.core.runtime.Path; import com.google.gson.Gson; -import xyz.veronie.bgg.types.EventConstants; -import xyz.veronie.bgg.types.SourceFilter; - public enum ThingProvider { INSTANCE; @@ -48,8 +43,8 @@ public enum ThingProvider { } - // helper functino for subtractThingMetas - private static Predicate thingEqual(ThingMetaData other) + // helper function for subtractThingMetas + private static Predicate thingEqual(final ThingMetaData other) { return p -> p.getId() == other.getId(); } @@ -80,9 +75,12 @@ public enum ThingProvider { String resultList = gson.toJson(this.thingMetas); try { + Path filesPath = new Path("result_" + Long.toString(System.currentTimeMillis())); + System.out.println("File output path: " + filesPath); BufferedWriter writer = new BufferedWriter( - new FileWriter("result_" + Long.toString(System.currentTimeMillis()))); + new FileWriter(filesPath.toString())); writer.write(resultList); + writer.close(); } catch (IOException e) { e.printStackTrace(); @@ -96,13 +94,13 @@ public enum ThingProvider { return thingMetas; } - @Inject - @Optional - private void subscribeTopicSourceChanged - (@UIEventTopic(EventConstants.TOPIC_TAG_RESULT) - String str) { - System.out.println("Tag result now."); - this.tagResult(); - } +// @Inject +// @Optional +// private void subscribeTopicTagResult +// (@UIEventTopic(EventConstants.TOPIC_TAG_RESULT) +// String empty) { +// System.out.println("TOPIC_TAG_RESULT: Tag result now."); +// this.tagResult(); +// } } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java index 007ea58..66c83b4 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java @@ -21,10 +21,10 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; import xyz.veronie.bgg.result.ResultConfigManager; import xyz.veronie.bgg.types.EventConstants; @@ -46,13 +46,16 @@ public class BggUserSourceFilter { @Inject private IEventBroker eventBroker; @Inject private ResultConfigManager configManager; + + private Combo cbUserName; public void create(Composite parent, int style) { - GridLayout filterLayout = new GridLayout(5, false); - parent.setLayout(filterLayout); + Composite mainCompo = new Composite(parent, SWT.FILL); + mainCompo.setLayout(new GridLayout(5, false)); + mainCompo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - Label lblUser = new Label(parent, SWT.LEFT); + Label lblUser = new Label(mainCompo, SWT.LEFT); lblUser.setText("User name: "); lblUser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); @@ -69,7 +72,7 @@ public class BggUserSourceFilter { // e1.printStackTrace(); // } - Combo cbUserName = new Combo(parent, SWT.DROP_DOWN); + cbUserName = new Combo(mainCompo, SWT.DROP_DOWN); cbUserName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); cbUserName.setText(configManager.getResultConfig().user); cbUserName.addSelectionListener(new SelectionAdapter() { @@ -90,6 +93,8 @@ public class BggUserSourceFilter { } }); + CommonControls.makeEmptySpace(mainCompo, 1); + // Button btEditUsers = new Button(parent, SWT.PUSH); // btEditUsers.setText("edit users"); // btEditUsers.setEnabled(false); @@ -97,14 +102,12 @@ public class BggUserSourceFilter { // 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); + Label lblSubtype = new Label(mainCompo, SWT.LEFT); lblSubtype.setText("Subtypes: "); lblSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); - ComboViewer cbSubtypes = new ComboViewer(parent, SWT.READ_ONLY); + ComboViewer cbSubtypes = new ComboViewer(mainCompo, SWT.READ_ONLY); cbSubtypes.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); cbSubtypes.setContentProvider(ArrayContentProvider.getInstance()); List subtypes = new ArrayList(); @@ -123,37 +126,42 @@ public class BggUserSourceFilter { - Label infoLabel = new Label(parent, SWT.LEFT); + Composite flagsComposite = new Composite(mainCompo, SWT.FILL); + GridLayout layout = new GridLayout(4,false); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.horizontalSpan = 5; + flagsComposite.setLayoutData(gridData); + layout.horizontalSpacing = 15; + flagsComposite.setLayout(layout); + + Label infoLabel = new Label(flagsComposite, 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 = 5; + gdInfo.horizontalSpan = 4; infoLabel.setLayoutData(gdInfo); - makeFilter(parent, UserFlag.OWN); - makeFilter(parent, UserFlag.WTP); - CommonControls.makeEmptySpace(parent, 1); + makeFilter(flagsComposite, UserFlag.OWN); + makeFilter(flagsComposite, UserFlag.WTP); - makeFilter(parent, UserFlag.PREVIOUSLY_OWNED); - makeFilter(parent, UserFlag.WTB); - CommonControls.makeEmptySpace(parent, 1); + makeFilter(flagsComposite, UserFlag.PREVIOUSLY_OWNED); + makeFilter(flagsComposite, UserFlag.WTB); - makeFilter(parent, UserFlag.TRADE); - makeFilter(parent, UserFlag.WISHLIST); - CommonControls.makeEmptySpace(parent, 1); + makeFilter(flagsComposite, UserFlag.TRADE); + makeFilter(flagsComposite, UserFlag.WISHLIST); - makeFilter(parent, UserFlag.WANT); - makeFilter(parent, UserFlag.PREORDERED); - CommonControls.makeEmptySpace(parent, 1); + makeFilter(flagsComposite, UserFlag.WANT); + makeFilter(flagsComposite, UserFlag.PREORDERED); - makeFilter(parent, UserFlag.RATED); - makeFilter(parent, UserFlag.COMMENT); - CommonControls.makeEmptySpace(parent, 1); + makeFilter(flagsComposite, UserFlag.RATED); + makeFilter(flagsComposite, UserFlag.COMMENT); - makeFilter(parent, UserFlag.PLAYED); + makeFilter(flagsComposite, UserFlag.PLAYED); - parent.pack(); - parent.getParent().pack(); - parent.layout(); +// flagsComposite.pack(); +// flagsComposite.getParent().pack(); +// flagsComposite.layout(); + mainCompo.pack(); + mainCompo.layout(true, true); } @@ -161,7 +169,7 @@ public class BggUserSourceFilter { // Filters are tri-state: include iff has flag, include iff it does not have the flag, // don't care if it has that flag. // TODO: create a three-way toggle button instead. - private void makeFilter(Composite parent, UserFlag key) { + private void makeFilter(Composite parent, final UserFlag key) { ComboViewer filterCombo = new ComboViewer(parent, SWT.READ_ONLY); filterCombo.setContentProvider(ArrayContentProvider.getInstance()); diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java index ac8134a..2949a8b 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java @@ -9,7 +9,6 @@ import org.eclipse.e4.core.di.annotations.Creatable; 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; @@ -39,6 +38,7 @@ public class FamilySourceFilter { @Inject private IEventBroker eventBroker; @Inject private ResultConfigManager configManager; private StyledText confLabel; + private Combo cbFamilyId; public void create(Composite parent, int style) { GridLayout filterLayout = new GridLayout(2, false); @@ -48,7 +48,7 @@ public class FamilySourceFilter { lblFamily.setText("Family ID: "); lblFamily.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - Combo cbFamilyId = new Combo(parent, SWT.DROP_DOWN); + cbFamilyId = new Combo(parent, SWT.DROP_DOWN); cbFamilyId.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); Integer fid = configManager.getResultConfig().familyId; @@ -63,7 +63,7 @@ public class FamilySourceFilter { System.out.println("set family id to '" + configManager.getResultConfig().familyId + "'"); } catch (NumberFormatException ex) { - MessageDialog.openError(parent.getShell(), "Input error", "FamilyId must be a whole number."); + eventBroker.send(EventConstants.TOPIC_STATUS, "[ERROR] GeeklistId must be a whole number."); } System.out.println("set family id to '" + configManager.getResultConfig().familyId + "'"); } @@ -77,7 +77,7 @@ public class FamilySourceFilter { System.out.println("set family id to '" + configManager.getResultConfig().geeklistId + "'"); } catch (NumberFormatException ex) { - MessageDialog.openError(parent.getShell(), "Input error", "FamilyId must be a whole number."); + eventBroker.send(EventConstants.TOPIC_STATUS, "[ERROR] GeeklistId must be a whole number."); } System.out.println("set family id to '" + configManager.getResultConfig().familyId + "'"); } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java index a4fcbea..7884bb3 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java @@ -6,7 +6,6 @@ import org.eclipse.e4.core.di.annotations.Creatable; 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.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.FocusEvent; @@ -30,6 +29,7 @@ public class GeeklistSourceFilter { @Inject private ResultConfigManager configManager; private StyledText confLabel; + private Combo cbGeeklistId; public void create(Composite parent, int style) { GridLayout filterLayout = new GridLayout(2, false); @@ -39,7 +39,7 @@ public class GeeklistSourceFilter { lblGeeklist.setText("Geeklist ID: "); lblGeeklist.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - Combo cbGeeklistId = new Combo(parent, SWT.DROP_DOWN); + cbGeeklistId = new Combo(parent, SWT.DROP_DOWN); Integer gid = configManager.getResultConfig().geeklistId; if(gid != null) { cbGeeklistId.setText(Integer.toString(gid)); @@ -52,7 +52,7 @@ public class GeeklistSourceFilter { System.out.println("set geeklist id to '" + configManager.getResultConfig().geeklistId + "'"); } catch (NumberFormatException ex) { - MessageDialog.openError(parent.getShell(), "Input error", "GeeklistId must be a whole number."); + eventBroker.send(EventConstants.TOPIC_STATUS, "[ERROR] GeeklistId must be a whole number."); } } }); @@ -65,7 +65,7 @@ public class GeeklistSourceFilter { System.out.println("set geeklist id to '" + configManager.getResultConfig().geeklistId + "'"); } catch (NumberFormatException ex) { - MessageDialog.openError(parent.getShell(), "Input error", "GeeklistId must be a whole number."); + eventBroker.send(EventConstants.TOPIC_STATUS, "[ERROR] GeeklistId must be a whole number."); } } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleSaveGamelist.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleSaveGamelist.java new file mode 100644 index 0000000..2113108 --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/HandleSaveGamelist.java @@ -0,0 +1,23 @@ + +package xyz.veronie.bgg.ui.handlers; + +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; + +import xyz.veronie.bgg.result.ThingProvider; + +public class HandleSaveGamelist { + + @Execute + public void execute() { + ThingProvider.INSTANCE.tagResult(); + } + + + @CanExecute + public boolean canExecute() { + // TODO + return true; + } + +} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java index 898e8b9..4bae887 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java @@ -13,6 +13,8 @@ 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.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -29,8 +31,6 @@ 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); @@ -42,14 +42,12 @@ public class BggResultPart { createViewer(main); statsLabel = new Label(main, SWT.FILL); - statsLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + statsLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, 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, ""); - }); + + + } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/DownloadThingDetailsPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/DownloadThingDetailsPart.java new file mode 100644 index 0000000..d33363f --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/DownloadThingDetailsPart.java @@ -0,0 +1,225 @@ +package xyz.veronie.bgg.ui.parts; + + +import javax.annotation.PostConstruct; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.ProgressProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +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.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.ProgressBar; + +import xyz.veronie.bgg.ui.helpers.CommonControls; +import xyz.veronie.bgg.ui.result.DownloadProgressMonitor; + +public class DownloadThingDetailsPart { + + private DownloadProgressMonitor monitor; + private Button extendedInfoCheck; + private Button downloadAllPlaysCheck; + + @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(2, false); + main.setLayout(layout); + + Composite loadGamesComposite = new Composite(main, SWT.FILL); + loadGamesComposite.setLayout(new GridLayout(1, false)); + loadGamesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + loadGamesComposite.setBackground(main.getDisplay().getSystemColor(SWT.COLOR_WHITE)); + createLoadGamesControls(loadGamesComposite); + + Composite loadOptionsComposite = new Composite(main, SWT.FILL); + loadOptionsComposite.setLayout(new GridLayout(1, false)); + loadOptionsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + loadOptionsComposite.setBackground(main.getDisplay().getSystemColor(SWT.COLOR_WHITE)); + createLoadOptionsControls(loadOptionsComposite); + + Composite runNanDeckComposite = new Composite(main, SWT.FILL); + runNanDeckComposite.setLayout(new GridLayout(1, false)); + runNanDeckComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + runNanDeckComposite.setBackground(main.getDisplay().getSystemColor(SWT.COLOR_WHITE)); + createRunNanDeckControls(runNanDeckComposite); + + Composite nanDeckOptionsComposite = new Composite(main, SWT.FILL); + nanDeckOptionsComposite.setLayout(new GridLayout(1, false)); + nanDeckOptionsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + nanDeckOptionsComposite.setBackground(main.getDisplay().getSystemColor(SWT.COLOR_WHITE)); + createNandeckOptionsControl(nanDeckOptionsComposite); + + } + + private void createNandeckOptionsControl(Composite compo) { + // Combo with ("Wait for user input", "Create PDF", "Print on default printer", "Save BMP images", + // "Save JPG images", "Save PNG images", Save GIF images", "Save GIFa images"); + + } + + private void createLoadOptionsControls(Composite compo) { + Group optionsGroup = new Group(compo, SWT.SHADOW_ETCHED_IN); + GridLayout layout = new GridLayout(3, false); + layout.horizontalSpacing = 15; + optionsGroup.setLayout(layout); + optionsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + optionsGroup.setText("Download options"); + + Label gamesLbl = new Label(optionsGroup, SWT.LEFT); + gamesLbl.setText("Games"); + ComboViewer gamesCombo = new ComboViewer(optionsGroup); + CommonControls.makeEmptySpace(optionsGroup, 1); + + Label resolutionLbl = new Label(optionsGroup, SWT.LEFT); + resolutionLbl.setText("Resolution"); + ComboViewer resolutionCombo = new ComboViewer(optionsGroup); + CommonControls.makeEmptySpace(optionsGroup, 1); + + Label imagesLbl = new Label(optionsGroup, SWT.LEFT); + imagesLbl.setText("Images"); + ComboViewer imagesCombo = new ComboViewer(optionsGroup); + CommonControls.makeEmptySpace(optionsGroup, 1); + + + + Button onlyNewCheck = new Button(optionsGroup, SWT.CHECK); + onlyNewCheck.setText("Only new"); + + Button usePersNamesCheck = new Button(optionsGroup, SWT.CHECK); + usePersNamesCheck.setText("Use pers. names"); + usePersNamesCheck.setEnabled(false); + + Button only1DesignerCheck = new Button(optionsGroup, SWT.CHECK); + only1DesignerCheck.setText("Only one designer"); + only1DesignerCheck.setEnabled(false); + + + Button withDescCheck = new Button(optionsGroup, SWT.CHECK); + withDescCheck.setText("With description"); + + Button usePersImagesCheck = new Button(optionsGroup, SWT.CHECK); + usePersImagesCheck.setText("Use pers. images"); + usePersImagesCheck.setEnabled(false); + + Button only1PublisherCheck = new Button(optionsGroup, SWT.CHECK); + only1PublisherCheck.setText("Only one publisher"); + only1PublisherCheck.setEnabled(false); + + + Button limitDescCheck = new Button(optionsGroup, SWT.CHECK); + limitDescCheck.setText("Limit description"); + + Button useRecBestInfoCheck = new Button(optionsGroup, SWT.CHECK); + useRecBestInfoCheck.setText("Use rec./best info"); + useRecBestInfoCheck.setEnabled(false); + + Button only1ArtistCheck = new Button(optionsGroup, SWT.CHECK); + only1ArtistCheck.setText("Only one artist"); + only1ArtistCheck.setEnabled(false); + + + + Button downloadVotesCheck = new Button(optionsGroup, SWT.CHECK); + downloadVotesCheck.setText("Download votes"); + downloadVotesCheck.setEnabled(false); + downloadVotesCheck.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + extendedInfoCheck.setEnabled(true); + } + }); + + Button brnDetailCheck = new Button(optionsGroup, SWT.CHECK); + brnDetailCheck.setText("B/R/N detail"); + brnDetailCheck.setEnabled(false); + + Button reloadDataCheck = new Button(optionsGroup, SWT.CHECK); + reloadDataCheck.setText("Reload data"); + reloadDataCheck.setEnabled(false); + + + + extendedInfoCheck = new Button(optionsGroup, SWT.CHECK); + extendedInfoCheck.setText(" Extended info"); + extendedInfoCheck.setEnabled(false); // enabled when download votes is checked + + Button downloadPlaysCheck = new Button(optionsGroup, SWT.CHECK); + downloadPlaysCheck.setText("Download plays"); + downloadPlaysCheck.setEnabled(false); + downloadPlaysCheck.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + downloadAllPlaysCheck.setEnabled(true); + } + }); + + Button reloadImagesCheck = new Button(optionsGroup, SWT.CHECK); + reloadImagesCheck.setText("Reload images"); + reloadImagesCheck.setEnabled(false); + + + + Button downloadLangCheck = new Button(optionsGroup, SWT.CHECK); + downloadLangCheck.setText("Download lang."); + downloadLangCheck.setEnabled(false); + + downloadAllPlaysCheck = new Button(optionsGroup, SWT.CHECK); + downloadAllPlaysCheck.setText(" Download plays (all)"); + downloadAllPlaysCheck.setEnabled(false); // enabled when download plays checked + + Button ReloadQRCodesCheck = new Button(optionsGroup, SWT.CHECK); + ReloadQRCodesCheck.setText("Reload QR codes"); + ReloadQRCodesCheck.setEnabled(false); + + + Button namesImgCheck = new Button(optionsGroup, SWT.CHECK); + namesImgCheck.setText("Names in images"); + namesImgCheck.setEnabled(false); + + Button useQrCodesCheck = new Button(optionsGroup, SWT.CHECK); + useQrCodesCheck.setText("Use QR codes"); + useQrCodesCheck.setEnabled(false); + + } + + private void createRunNanDeckControls(Composite compo) { + Button runNandeckBtn = new Button(compo, SWT.LEFT); + runNandeckBtn.setText("Run nanDeck"); + runNandeckBtn.addSelectionListener(new SelectionAdapter() { + + }); + } + + private void createLoadGamesControls(Composite compo) { + + Button loadGamesBtn = new Button(compo, SWT.LEFT); + loadGamesBtn.setText("Load games"); + loadGamesBtn.addSelectionListener(new SelectionAdapter() { + + }); + + ProgressBar progressBar = new ProgressBar(compo, SWT.SMOOTH); + progressBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + + monitor = new DownloadProgressMonitor(); + + Job.getJobManager().setProgressProvider(new ProgressProvider() { + @Override + public IProgressMonitor createMonitor(Job job) { + return monitor.addJob(job); + } + }); + + } + +} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadThingDetailsPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadThingDetailsPart.java deleted file mode 100644 index 29d1a7b..0000000 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadThingDetailsPart.java +++ /dev/null @@ -1,22 +0,0 @@ -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); - - } - -} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/PreparePart.java similarity index 80% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/PreparePart.java index 7e9c760..84bebe4 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/PreparePart.java @@ -7,6 +7,7 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.e4.core.services.events.IEventBroker; +import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; @@ -34,7 +35,6 @@ import xyz.veronie.bgg.result.ThingProvider; import xyz.veronie.bgg.types.EventConstants; import xyz.veronie.bgg.types.ResultAction; import xyz.veronie.bgg.types.SourceFilter; -import xyz.veronie.bgg.types.Subtype; import xyz.veronie.bgg.ui.filters.AgeSourceFilter; import xyz.veronie.bgg.ui.filters.BggUserSourceFilter; import xyz.veronie.bgg.ui.filters.FamilySourceFilter; @@ -48,7 +48,10 @@ import xyz.veronie.bgg.ui.helpers.CommonControls; /// Has controls to download a list of thing IDs (+some meta info) from BGG. /// There are different ways to configure which IDs to retrieve. -public class LoadFromBggPart { +public class PreparePart { + + @Inject + EPartService partService; @Inject private ResultConfigManager configManager; @@ -64,15 +67,14 @@ public class LoadFromBggPart { @Inject private YearSourceFilter yearSourceFilter; @Inject private SearchSourceFilter searchSourceFilter; @Inject private BggApi bggApi; + + private Composite mainComposite; @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); - + mainComposite = new Composite(parent, SWT.FILL); + mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + mainComposite.setLayout(new GridLayout(1, false)); // // contains configuration options for download of the bgg thing ID list // Group dlConfigGroup = new Group(main, SWT.SHADOW_ETCHED_IN); @@ -82,12 +84,15 @@ public class LoadFromBggPart { // GridLayout layoutG = new GridLayout(2, false); // dlConfigGroup.setLayout(layoutG); - Label lblSource = new Label(main, SWT.LEFT); + Composite sourceSelectCompo = new Composite(mainComposite, SWT.FILL); + sourceSelectCompo.setLayout(new GridLayout(2, false)); + + Label lblSource = new Label(sourceSelectCompo, SWT.LEFT); lblSource.setText("Source: "); lblSource.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false)); // choose the bgg data source - ComboViewer cbSource = new ComboViewer(main, SWT.READ_ONLY); + ComboViewer cbSource = new ComboViewer(sourceSelectCompo, SWT.READ_ONLY); cbSource.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); cbSource.setContentProvider(ArrayContentProvider.getInstance()); List sources = new ArrayList(); @@ -99,20 +104,14 @@ public class LoadFromBggPart { cbSource.setSelection(new StructuredSelection(configManager.getResultConfig().source)); // listener is configured further below - CommonControls.makeEmptySpace(main, 3); + CommonControls.makeEmptySpace(mainComposite, 2); - - + // area to display filter controls - // next row: - - // area to display filter controls in - Group gFilters = new Group(main, SWT.SHADOW_ETCHED_IN); + Group gFilters = new Group(mainComposite, SWT.SHADOW_ETCHED_IN); gFilters.setText(""); - GridData gdf = new GridData(SWT.FILL, SWT.FILL, false, false); - gdf.horizontalSpan = 5; - gFilters.setLayoutData(gdf); + gFilters.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); showFilter(gFilters, (IStructuredSelection)cbSource.getSelection()); // set content to initial selection cbSource.addSelectionChangedListener(new ISelectionChangedListener() { // later, its content will be set via the dropdown @@ -127,16 +126,14 @@ public class LoadFromBggPart { }); - // next row: - CommonControls.makeEmptySpace(main, 5); - - // next row + Composite fetchCompo = new Composite(mainComposite, SWT.FILL); + fetchCompo.setLayout(new GridLayout(4, false)); + // choose action on result list - Button btDownload = new Button(main, SWT.PUSH); + Button btDownload = new Button(fetchCompo, SWT.PUSH); GridData gd = new GridData(SWT.LEFT, SWT.FILL, false, false); - gd.horizontalSpan = 2; btDownload.setLayoutData(gd); btDownload.setText("Fetch"); btDownload.addSelectionListener(new SelectionAdapter() { @@ -150,7 +147,7 @@ public class LoadFromBggPart { if(selection.getFirstElement() == SourceFilter.BGG_USER) { String user = resultConfig.user; if(user == null || user.isEmpty()) { - MessageDialog.openError(main.getShell(), "", "Please enter a user name."); + MessageDialog.openError(mainComposite.getShell(), "", "Please enter a user name."); return; } else { eventBroker.send(EventConstants.TOPIC_STATUS, "Fetching " + selection.getFirstElement().toString() + " '" + user + "'..."); @@ -159,14 +156,14 @@ public class LoadFromBggPart { useThingsOnResult(thingMetas); } catch(IllegalArgumentException ex) { - MessageDialog.openError(main.getShell(), "", ex.getMessage()); + MessageDialog.openError(mainComposite.getShell(), "", ex.getMessage()); } } } else if(selection.getFirstElement() == SourceFilter.GEEKLIST) { Integer geeklistId = resultConfig.geeklistId; if(geeklistId == null) { - MessageDialog.openError(main.getShell(), "", "Please enter a geeklist id."); + MessageDialog.openError(mainComposite.getShell(), "", "Please enter a geeklist id."); return; } else { eventBroker.send(EventConstants.TOPIC_STATUS, "Fetching for geeklist id '" + geeklistId + "'"); @@ -175,13 +172,13 @@ public class LoadFromBggPart { useThingsOnResult(thingMetas); } catch(IllegalArgumentException ex) { - MessageDialog.openError(main.getShell(), "", ex.getMessage()); + MessageDialog.openError(mainComposite.getShell(), "", ex.getMessage()); } } } else if(selection.getFirstElement() == SourceFilter.FAMILY) { Integer familyId = resultConfig.familyId; if(familyId == null) { - MessageDialog.openError(main.getShell(), "", "Please enter a family id."); + MessageDialog.openError(mainComposite.getShell(), "", "Please enter a family id."); return; } else { eventBroker.send(EventConstants.TOPIC_STATUS, "Fetching for family id '" + familyId + "'"); @@ -190,7 +187,7 @@ public class LoadFromBggPart { useThingsOnResult(thingMetas); } catch(IllegalArgumentException ex) { - MessageDialog.openError(main.getShell(), "", ex.getMessage()); + MessageDialog.openError(mainComposite.getShell(), "", ex.getMessage()); } } } @@ -217,11 +214,11 @@ public class LoadFromBggPart { }); - Label lblAct = new Label(main, SWT.LEFT); + Label lblAct = new Label(fetchCompo, SWT.LEFT); lblAct.setText("and"); lblAct.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false)); - ComboViewer cbAct = new ComboViewer(main, SWT.READ_ONLY); + ComboViewer cbAct = new ComboViewer(fetchCompo, SWT.READ_ONLY); GridData gdact = new GridData(SWT.FILL, SWT.FILL, false, false); cbAct.getCombo().setLayoutData(gdact); cbAct.setContentProvider(ArrayContentProvider.getInstance()); @@ -240,29 +237,18 @@ public class LoadFromBggPart { }); - Label toResultLabel = new Label(main, SWT.LEFT); + Label toResultLabel = new Label(fetchCompo, SWT.LEFT); toResultLabel.setText("result"); toResultLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - -// // Start retrieval when download button is pushed -// // TODO: how do I locate icons? -// Button btDownload = new Button(main, SWT.PUSH); -// try { -// Image dlIcon = new Image(getDisplay(), -// getClass().getResourceAsStream("C:\\Users/goya/workspace/icons/icons/material_design/png/download-button.png")); -// btDownload.setImage(dlIcon); -// } -// catch(Exception ex) { -// btDownload.setText("Download now"); -// } - main.pack(); + mainComposite.pack(); + mainComposite.layout(); } /// show different filter controls depending on selection in cbSource ComboViewer - public void showFilter(Composite parent, IStructuredSelection selection) { + private void showFilter(Composite parent, IStructuredSelection selection) { SourceFilter elem = (SourceFilter) selection.getFirstElement(); // clean up @@ -300,6 +286,9 @@ public class LoadFromBggPart { System.out.println("construct " + elem + " (not implemented yet, try another one)"); } + parent.pack(); + mainComposite.pack(); + mainComposite.layout(true, true); } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/StatusBar.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/StatusBar.java index 8c4ffa7..6a7e796 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/StatusBar.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/StatusBar.java @@ -42,12 +42,13 @@ public class StatusBar { @Inject @Optional - private void subscribeTopicSourceChanged + private void subscribeTopicStatusChanged (@UIEventTopic(EventConstants.TOPIC_STATUS) String text) { statusLabel.setText(text); statusLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); statusLabel.getParent().pack(); + System.out.println("Status: " + text); } } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/result/DownloadProgressMonitor.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/result/DownloadProgressMonitor.java new file mode 100644 index 0000000..421d80c --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/result/DownloadProgressMonitor.java @@ -0,0 +1,14 @@ +package xyz.veronie.bgg.ui.result; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; + +public class DownloadProgressMonitor extends NullProgressMonitor { + + public IProgressMonitor addJob(Job job) { + // TODO Auto-generated method stub + return null; + } + +}