From e0023374dbc5539e9403a37a3ea334225eb4d9dd Mon Sep 17 00:00:00 2001 From: G S Senthil Kumar Date: Mon, 10 Aug 2015 13:16:00 +0530 Subject: [PATCH] Eclipse plug-in for service provider. This change-set includes the following: 1. Views for Properties, Attributes and Log. 2. Support for manually changing the attributes' values. 3. Attribute level and resource level automation support. 4. Updates to exiting UI modules. 5. Icons and images which are used in wizards and views. 6. README file which explains how to import and run the plug-in. Change-Id: I9f0a405da6ebeec932c9f5b1a2c53b92ab225de7 Signed-off-by: G S Senthil Kumar Reviewed-on: https://gerrit.iotivity.org/gerrit/2150 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../ServiceProviderPlugin/.classpath | 12 +- .../eclipse-plugin/ServiceProviderPlugin/.project | 52 +- .../ServiceProviderPlugin/META-INF/MANIFEST.MF | 2 +- .../ServiceProviderPlugin/README.txt | 20 + .../ServiceProviderPlugin/build.properties | 5 +- .../ServiceProviderPlugin/icons/clear_d.gif | Bin 0 -> 364 bytes .../ServiceProviderPlugin/icons/clear_e.gif | Bin 0 -> 595 bytes .../ServiceProviderPlugin/icons/debug_log.gif | Bin 0 -> 348 bytes .../ServiceProviderPlugin/icons/delete_d.gif | Bin 0 -> 221 bytes .../ServiceProviderPlugin/icons/delete_e.gif | Bin 0 -> 351 bytes .../ServiceProviderPlugin/icons/error_log.gif | Bin 0 -> 353 bytes .../ServiceProviderPlugin/icons/export_log_d.gif | Bin 0 -> 918 bytes .../ServiceProviderPlugin/icons/export_log_e.gif | Bin 0 -> 329 bytes .../ServiceProviderPlugin/icons/filter_d.gif | Bin 0 -> 112 bytes .../ServiceProviderPlugin/icons/filter_e.gif | Bin 0 -> 159 bytes .../ServiceProviderPlugin/icons/info_log.gif | Bin 0 -> 267 bytes .../ServiceProviderPlugin/icons/lock_d.gif | Bin 0 -> 588 bytes .../ServiceProviderPlugin/icons/lock_e.gif | Bin 0 -> 626 bytes .../ServiceProviderPlugin/icons/log_details_e.gif | Bin 0 -> 354 bytes .../ServiceProviderPlugin/icons/oic_logo_16x16.png | Bin 0 -> 1108 bytes .../ServiceProviderPlugin/icons/oic_logo_32x32.png | Bin 0 -> 1855 bytes .../ServiceProviderPlugin/icons/oic_logo_64x64.png | Bin 0 -> 16540 bytes .../ServiceProviderPlugin/icons/prop_d.gif | Bin 0 -> 218 bytes .../ServiceProviderPlugin/icons/prop_e.gif | Bin 0 -> 343 bytes .../ServiceProviderPlugin/icons/trash_e.gif | Bin 0 -> 590 bytes .../ServiceProviderPlugin/icons/tree_mode_d.gif | Bin 0 -> 83 bytes .../ServiceProviderPlugin/icons/tree_mode_e.gif | Bin 0 -> 98 bytes .../ServiceProviderPlugin/icons/unknown_log.gif | Bin 0 -> 69 bytes .../ServiceProviderPlugin/icons/warning_log.gif | Bin 0 -> 338 bytes .../ServiceProviderPlugin/libs/Simulator.jar | Bin 0 -> 14656 bytes .../ServiceProviderPlugin/plugin.xml | 52 +- .../oic/simulator/logger/LogContentProvider.java | 46 + .../src/oic/simulator/logger/LogEntry.java | 39 + .../src/oic/simulator/logger/LogLabelProvider.java | 38 + .../src/oic/simulator/logger/LoggerCallback.java | 55 + .../oic/simulator/serviceprovider/Activator.java | 58 +- .../listener/IAutomationUIListener.java | 7 + .../serviceprovider/listener/ILogUIListener.java | 11 + .../listener/IResourceListChangedListener.java | 13 - .../listener/IResourceListChangedUIListener.java | 7 + .../listener/IResourceModelChangedUIListener.java | 8 + .../IResourceSelectionChangedUIListener.java | 5 + .../serviceprovider/manager/LogManager.java | 253 +++++ .../serviceprovider/manager/ResourceManager.java | 1143 ++++++++++++++++---- .../perspective/PerspectiveFactory.java | 11 +- .../resource/AttributeValueType.java | 6 +- .../resource/AutomationSettingHelper.java | 111 ++ .../serviceprovider/resource/MetaProperty.java | 27 + .../resource/ModelChangeNotificationType.java | 5 + .../resource/ResourceAttribute.java | 109 +- .../resource/SimulatorResource.java | 61 +- .../resource/StandardConfiguration.java | 5 +- .../simulator/serviceprovider/utils/Constants.java | 74 +- .../utils/{Convertion.java => Utility.java} | 47 +- .../serviceprovider/view/AttributeView.java | 1020 ++++++++++++++++- .../serviceprovider/view/LogDetailsDialog.java | 123 +++ .../simulator/serviceprovider/view/LogView.java | 692 +++++++++++- .../serviceprovider/view/MetaPropertiesView.java | 185 ++++ .../view/MultiResourceOrchestrationView.java | 9 +- .../serviceprovider/view/ResourceManagerView.java | 404 ++++--- .../view/dialogs/CreateResourcePage.java | 17 +- .../view/dialogs/CreateResourceWizard.java | 15 +- .../view/dialogs/DeleteCategory.java | 2 +- .../view/dialogs/DeleteResourcePage.java | 12 +- .../view/dialogs/DeleteResourceWizard.java | 21 +- .../serviceprovider/view/dialogs/FilterDialog.java | 75 ++ .../view/dialogs/ResourceWizardDialog.java | 3 +- 67 files changed, 4350 insertions(+), 510 deletions(-) create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/clear_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/clear_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/debug_log.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/delete_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/delete_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/error_log.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/export_log_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/export_log_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/filter_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/filter_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/info_log.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/lock_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/lock_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/log_details_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_16x16.png create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_32x32.png create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_64x64.png create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/prop_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/prop_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/trash_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/tree_mode_d.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/tree_mode_e.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/unknown_log.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/warning_log.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/libs/Simulator.jar create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogContentProvider.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogEntry.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogLabelProvider.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LoggerCallback.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IAutomationUIListener.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/ILogUIListener.java delete mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedListener.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedUIListener.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceModelChangedUIListener.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceSelectionChangedUIListener.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/LogManager.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AutomationSettingHelper.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/MetaProperty.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ModelChangeNotificationType.java rename service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/{Convertion.java => Utility.java} (55%) create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogDetailsDialog.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/FilterDialog.java diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath index 95052f6..61b8255 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath @@ -1,8 +1,8 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.project b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.project index 9a2dee2..65d5304 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.project +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.project @@ -1,28 +1,28 @@ - ServiceProviderPlugin - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - + ServiceProviderPlugin + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/META-INF/MANIFEST.MF b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/META-INF/MANIFEST.MF index 821a2e6..08798e4 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/META-INF/MANIFEST.MF +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/META-INF/MANIFEST.MF @@ -9,5 +9,5 @@ Require-Bundle: org.eclipse.ui, Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Bundle-NativeCode: libs/libSimulatorManager.so -Bundle-ClassPath: libs/ServiceProvider.jar, +Bundle-ClassPath: libs/Simulator.jar, . diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt new file mode 100644 index 0000000..bb5b937 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt @@ -0,0 +1,20 @@ +Service Provider eclipse plug-in + +Pre-requisites +-------------- + 1.Build the IoTivity project for linux: + Run the "scons" command in iotivity home directory. + It generates the libraries in ~/iotivity/out/linux//release directory. + 2.Copy the libraries mentioned below into the libs folder of the plug-in project. + Required libraries: libSimulatorManager.so, liboc.so, liboctbstack.so, and liboc_logger.so + +Steps to run the plug-in +------------------------ + 1.Import the plug-in project from ~/iotivity/service/simulator/java/eclipse-plugin/ into Eclipse IDE as given below. + File -> Import -> Select 'Existing projects into Workspace' under General category -> click next -> Browse to the above mentioned location -> + click Finish. + 2.Set the LD_LIBRARY_PATH environment variable + Right click the project -> Properties -> Run/Debug Settings -> Edit -> select 'Environment' tab -> click on 'Select' -> check LD_LIBRARY_PATH option -> Ok. + Edit the LD_LIBRARY_PATH and add the complete path to the libs folder of the plug-in project -> Apply -> OK. + Then Apply -> OK to close the properties window. + 2.Right click the project -> Run As Eclipse Application. \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties index a36114b..0a482ed 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties @@ -3,4 +3,7 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ libs/,\ - icons/ + icons/,\ + plugin.xml,\ + ,\ + libs/Simulator.jar \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/clear_d.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/clear_d.gif new file mode 100644 index 0000000000000000000000000000000000000000..6775edfabb98762b8ce735171380920edc076efc GIT binary patch literal 364 zcmZ?wbhEHb6krfwxXQrr`}dz;zkdJx`Rm7zpAQ~BIehfgxeHfLow;!Q2KY#wb zefxI%_U+rYZQHbI)0#DFRqv0~ApMGF@$oHuXY?Afzt&YU@8#*FFH zr%#(U?f?J(3={yxpDc_F4B8AjATvOIVqoh$Ae!bOv##%ivfAOCFau8&wgXGj^h7d5 zgbic_SR0;xy2Hivydi4sR4$3$c5$5yZN&+Ub^IH-l?#g4`GgtjB!mRJx|kGH)9(*oeotO@Y}T67i#DHMvE%ZZJy-8O|Ni97&*$%czWwy;^S9r3 zo`1jp^2fthKi+)${p!QdZ$ExNd-wC(&%YnO{{Hms_tzi4zyJI_W5&cyo7UdHe|Of* z{<*XJmMv^wG_UL6rjotu%lB?5-?_GG%gWmI%NmdGpZDg~qvKl(k8UnLx~2Hg#?qZ@ zs#Y&v%S5&t*x!DuCAn{q`0`asHmv0urNPAKQAvYB_$;} zIXNyaE;cqcGBPqWG&DFkI4CG6FfcG6Ai&?>-_OtQ|Ns9C0}2#>vM@3*gfi%WTmgy` z2KEgNp{C6(&7tib?WP<(y|$*E9cHRboKu+W?9C^J>Z%9|aC6C9+u2x5)MuAemSmLN zAgMReQb|NuXu%?WgNcR`5^M(!OBhcylH0yhfQMJnWTKUV_?0Uxu3jz-u0F1z+G3{` zuzEW)`F=drwRH^dde6KTp?5HjDwPt!%ua0$DEtSh$2VJr-3M iJ8pc$DH7Bta+mRt9F_KB}J9`r#g`PUial&Z=(aTAtPl_67=023r2s zI@$6TwHkr_Rud1`7Oo7Na-@9f(eimG>*t+pSbDnc`M29^FHBf>VZxRxGqzuybNk)t z+iy>A1+ixzy}$O@{dGt0tv&T<^VL@ekKJ2)?B2SoFAr|mu;Ksz{|u-=@h1x-1A`TV z4oDc}CkD1khq(bBl2ZMLPY5)bJTtLWT$b7Cq1ErMC!G7Li2sW2?+d7K36Q@l~$Ly1U#YBsooW6^-@PxqPKL3{A|Gv{X5SW!+=g4YV~CR9FMOoP{je iSk%>&<(WN7oP-&e7#ZT6WeT^tiSBe;w`ad2gEavB?SN4L literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/delete_d.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/delete_d.gif new file mode 100644 index 0000000000000000000000000000000000000000..9e142981b2330ee95980dbfaf14f8b6c93f3b563 GIT binary patch literal 221 zcmV<303!cKNk%w1VGsZi0K@-;y*~!V=&CT4-&ceaL z|Ns900000000000A^8LW000~SEC2ui01yBW000GAASaGwX`bh%mg+`s&;_|7EYsW; zX<5|nJzP$L!BixbB1KrUBoI)Vab=`lFvmYpNmUxXz4%DF}bf}d|cDunVH>FGrOY- z+D{EEKZPcINzVS9ob?$uHn=&y~n$8D`1 z2l;<(sQc1T_xQ+>|Ns9p5DgT6vM@3*7&7R9bb$QCz*ci$MuCTpRKNR-^bncK1eb^v zqDfrti^MpzbSB1VUt0b}aql73M;xvKD|}WtK1fk5iV!?;_@hVR1O_f%UNKGv4?_+f zX(=fl4i6boi78XK>s@7pr?3jKN=S;#aFP{YATA>-vrJN4*4aRuZH4n{cJUaejf&+b%ltZ`Yw@A<{iLE#Es0saCN{wV^@&N+MqoU=Lk%4bN3s&FkWVC9j>%9h|}XJKSv bTe;d-LWoy{S7?<_wwK4gLx&GJGFSruf?#b8 literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/export_log_d.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/export_log_d.gif new file mode 100644 index 0000000000000000000000000000000000000000..030b93efadc34c791cfbc321526d4f48610c7e1f GIT binary patch literal 918 zcmZ?wbhEHb6krfw_|5lQBjMqZdLcm{o`eaGE&VL) zJbyfdnATdpE(wEz2MpKO#_Vp}>tUe4U=0A$gigBv literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/export_log_e.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/export_log_e.gif new file mode 100644 index 0000000000000000000000000000000000000000..5a0837d1e475ec48731c88f6d554a37750df4693 GIT binary patch literal 329 zcmZ?wbhEHb6krfwxXQp_Z$IBYe!fro^uXMCfjM(S@)ri=&J8YD7??XZC~s~=$&!eY z#Sx{8BTE;@R4k9LS)EY3I=*^Ea{bzr`n73I>suF|ZCiMD?&fRpK=ImD$qj2;7oBYb zp)(U!U0S~T*77~K)*rlUT(HErV6j8_a^9F(|NsAIpdL{C$->CMpvIsBG7{t`2DUVZ z$ps!dQvDvvnIT%LohlPQYwEbJT&CH{W#Fcfkd(lo*X}eWaeB?N3@5410-q@!PLq$b ze>&4(z$eb<-^j-+$H~RR-P7AE$IUJyBP}B~Ra#nBMsx}*6B`>d2iuZ`94lB>M7TII GSOWlifno0e literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/filter_d.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/filter_d.gif new file mode 100644 index 0000000000000000000000000000000000000000..ba6d891495f852cfda82fa5619ba45a63c14c644 GIT binary patch literal 112 zcmZ?wbhEHb6krfwSj51vZvBQ|zkY05x8T|1+bfsM`1t+Q8p}12WsEYxhqZ46z5UO4 xC{IX5qW?tG!t@NQxhzk8CmDO_&kQNvl+j$RV9uyFP1Eu=fc2X4FC}0Hs=5U literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/info_log.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/info_log.gif new file mode 100644 index 0000000000000000000000000000000000000000..3679f84ad88360690aeef62e7cebad04805fd795 GIT binary patch literal 267 zcmZ?wbhEHb6krfwI3mUH?eBjkw;sNvC7~1cZ@cj1_>~J^e*d4g?dbPE|9|}b|LgDn z?|=XQ`S<_ppZ|aV{r~y*|C>)=zy0~o5i;ZVzyCZj^FMw5`u5Y;fB*h-$Ik!w>FfXh z{~1t$;!hSv1_mhx9gr}{P6pPF1!{dMkz&mPEQbPS+!Ew*nJVa9Fs0qWf}xS2K#`+t zk<$Zq4n9Ucrw2wjgg%h@ldqTUVSreem&vYxnP5+P7=n)JdIBAKkon`_l6# zcb+}Ief9F$^JkC0d-Lq&^M~8FZC<}>?%EY|)-0dBdfBX%OJ?lYvg+geSMT4xSigGF zotu|VpEz{w%7uG(ZoC4jesJ&er;mpY9{m6R|G$6#{{H<7WH1ahp!k!8k%7U5K?me; zP@FKZuWWE>YHn$5cIfEr>S}Tj@1M{wJ;9+@Tx`ZnF@14fmZ>g%vt~+(Gczyf6J5PV zlz%<{N{QvmMYeIU3JI;$QB<^MViFeS<~+7i)!trJn~{;3hwIW*2L&5PM>_>uMkYb= z)mKb(tgLiQtRxu)-UwV#mXX(!)iQ9FWS_Fo%-q6MS2Kx2^3j6J%LC+!W*AI#Zsk#Q d;)!8kXprg>R&tr6V3;hpC_v6pl#7MI8US7A;iv!r literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/lock_e.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/lock_e.gif new file mode 100644 index 0000000000000000000000000000000000000000..68fd6cf39cac929152036675cc56c7edaf9217e9 GIT binary patch literal 626 zcmZ?wbhEHb6krfwc*el+=g+^tfB$8aO_rouLfByx#?%&}fyLWD1v0z5d?5PE7 zR`f5Qld)u0*3=25e?Oo8@@(7R_j~_-IP~|^@xPx={{4Jz+a#5*w>thj?Emv*)}Lqd z{ydxi=h=d%56*AwR@~CBd~lw{vQCTROI&x%bh)uN_rvwRn@8H8UYvU8{F;hr;pKHQ z>)Pa3H_IR0Pa$D!M)0=Ky*z@`A!~bBwKs})NlZBCiA&o%?WF#m~ z7}(D@q%}3Sv^Lvxbar($*&6px=(m|*(`0F^Jad+^ov|d3U6Ylu%F<;jM#i$5Moren z+8Z}%Gi}}4WMQJVTTOMJ0<*BNLX&x7KtQ~NgpQ6bAFrrxQ$kQmN>H4hp1PKpn21tZ zl3PS-YO)+gMdQHc12(!2 M&1HruY61+_0K&N{n*aa+ literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/log_details_e.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/log_details_e.gif new file mode 100644 index 0000000000000000000000000000000000000000..7ccc6a70317bf439c4178f66c40005ebf9e72314 GIT binary patch literal 354 zcmV-o0iFIwNk%w1VGsZi0M!5h^Y#1q`TT>Cv4fGYhm)>@lCgr3u!EAY?(+Kb_51ny z{P_9%hMK;NpTdTeu8Wqd@bvqWrpB7A%c8T-sJPRtyw%?5_}%CC-{|+`?D^;J`R(%h z^Y;7P=l9>~_}=LE;p+J6@cH)m`;eNb=I;6M_51Sn`<9)g_4xbu`TLcfq?@6kp`@Ir zsF8yg6Lgc~kJEFpM$VhkZHMJps4l$Db! zMJgGKdkh&TMI#`iq@*K74<3wT7#|i7MGhSu7qqms1VsV`2L`;o2Lc03#6v*o9xC)ddOBXA#-rCnMHU7xE!@2Sj73&xLkF-kkv6Gb8xZ$fBpIW|Bv7A z|GxeF^3&8^{megpef{_M|9=eioK}_=a$7g<7tBgeLziS`W&#BxLtL?0#>ub6Z>5z4 zB+%6`NY0qLSpCu6|Ef2yJcmiLn<`uJcp5}7aj|nTGBUE*cqqH{uMb+uC&$ms0qwv(~`0H|Ns9VbOXS#z!Po}B)zWayv)Ap%gln@d`wJ?Y(R}npSPc% z`}f1wXaE2G`}1k#v2JwDAU@ayjI1mm|1mJKFtaf-F|mMx7iinR-}heKcpfoHm64s5 z?a!xgAFvq!5d+%B>8#_zsxGMlQv~uaGcz*>2urRiSS#EX)(DeBrXgVfwC(%eD|?V7 z{vhDKPWTdOtG+7KrxI{ zU(bY@mq&t$hev{0R#xoKhmSb@kJW%r>o=@nm6ucf^XBc-pO>%PK{1`$oNVrCCFTB; Q?}E(rboFyt=akR{0Eu&^A^-pY literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_32x32.png b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..d02a216a8aeafce9d4446121122bf7970e7b4748 GIT binary patch literal 1855 zcmbu6eLT}!9LLYkwkEn|CWI(@AVp$Xs@siNCS-Z8u$VO|d1^!DMji_hE3TdtOH=Z= zl3GTjhwI8%TjjA-LYuTkvHP3*deuMokNdiP&+Bu}_nhzdd|%)9Ir8W7UZ6&FaC86= z1c3l}0C^usw`b6T0dRH(D*yn>01fE?6zoB;_CUJd{Se3)AZE^$;GhM7XP^cv!cA=^ z7cL2a8wMa}aumM$4`TfAvz-_Ht~2;a!P7idd}(G zJm#6R`2|InuN0TCu9jY_tg5c5<=nbm$7^hQ(A@H{_0h8qerK29xlq*CKk)j^;M;fa zha_X4#y?BH$R;KgTo6Eff3kn&!oXZgNF)M@R&YT|bXW)s61CW3milHlG&vk=xaOF$ zhHdtxiiX)nmL&1~JrV6HnoF$umP!<8Gi3h_Ea88VeFyu&B?5C05d3)v4A=ywr;TsS z>vyMrnO2n;q>P(my=6Nd99`OuJEF^rEq*oR?V-Ihsp_!JsgFviD3 zhG8G;m`qsrGBYGjQnCyup*LU9`MfU+^S)cJBRXE!=bfhLn@D<@O76?RlK9c_6@GrR zI9S>5jp)2!j;Y4HebU>tZP6R{y>GwY7eetKZZ4rFT~6hBH9jk5Iy?4P9AtkZ@(aGW z8xy+Eb+kL>H`Ec!2ZbLEf)^}b7b3;MNF$r{7m?XyZs)YxdDkRHo%Wo; zth?#nCm-d8rEseLkn)$?GR<Pqnk^`t!?9?cTEsVX#Dz)ohMQ{~A zmfaZbj*ISi;qc7me61j%tH;wPdRflL;bxltpZHay`14}EQzWF}r6qW1*Y*t3TOp8AV3Cl2*giztO7b4w{x+1htFPCHmh zd}P;!(#hq?0qwY7sBW3kvBBLTy}R1_0H-T#Xsx z=;U`r8C1Edn^jnglIq{D-?`)jxr8ecJT&nSctu+)2SU21wY1jvP2SVvlSjsFuGrF| z*PD!px(8oukI5O`NErFca`OgtJ3UKw^-=GP<90>msoaoqVPn5nbB_i?)mQAAVKt@F z(wL3A+sS0bv!BZWrMpHBL@8<2VZ(QJmTz(&Q`uQr&%`dSs8rjX#H1z;Rfck)lTVIh zT3Qt6Zf|mkyq;N3EHNxxO3ZzQk25CP@N>5Njgum{^%G>%{-XKe2T@ZT}X{Q!()uYe>z)vf=Bibb@ci?PHL0`mzJ#@{KY)ozm1-V}j2A z*0EJ1Fs^pRtC*Xt;oC)pyJB7sw4#)+a*7;%rzQ$W^iHF37j)lN@gbkHlw3bAS44VS wRcMdtn+a literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_64x64.png b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/oic_logo_64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..4fe3cbb87f4400ef1fcfd15e1d4becabbfeace94 GIT binary patch literal 16540 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 literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/trash_e.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/trash_e.gif new file mode 100644 index 0000000000000000000000000000000000000000..bf961b3e00675b71052fc1798198d0e0f31d24cc GIT binary patch literal 590 zcmd6kJ8u&~6h1W9<$X*!oHsx4P*fkrfp zkdUUJ*m5MATV9D~=q}xqQ*MR)7pRQ=FZjx%Qyl3#IqmYs`^&7v{xD|Uc&KP7F;pgq zp(k)4ai~m~(&B}xhMGsZ6+<9Uq60fF4U`vYJ~QEBW@4miai9VL<)PxS9w-z*60I^W z(k2E{NYzlThf;t^$(2LtMKaP@jif@uW2p?KWWi-Tid#Z*Ap<#uQ<*doI%k{~W&5X^^X5hv!nM~M!u#La@ zImXV}_N-<02`l`F&yytoF+Uoy`Grd>SC*ER^9w8~tUlTc-u8ln-PJ{_pIZ6_d0D))b^XTSFdZ${hFve zcv^Y!vQmFi5u0}(ZXI+tH@3IL{oD8M>^|>?V=veLG=FQyv9G_9(Tb>-T5K-=dHGsy T*s6DqlP~LgA8!8kORV`1ElJDZ literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/tree_mode_d.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/tree_mode_d.gif new file mode 100644 index 0000000000000000000000000000000000000000..62bdbe2f7d5cb0baf5eff443ddb49a46c345b857 GIT binary patch literal 83 zcmZ?wbhEHb6krfwn8?6z>db}pn|B^Mc<}%K|B63Z7#SFt8FUzc03^@Aq%x;}<>|dl mcLg1II^s86`cS8MvzgQJXifN+hIuEnmUfmc?p9`Hum%A56(6?% literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/tree_mode_e.gif b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/tree_mode_e.gif new file mode 100644 index 0000000000000000000000000000000000000000..dda8baeba997e4021e8eae9eeecdd95d090caf01 GIT binary patch literal 98 zcmZ?wbhEHb6krfwSj4~(Q?)9gZf#og#)(Uh=X7l^ny{;E%D(^q|117vVPs%nXV75) z0+3n;X7!3)cm5gJIXq=zmI?0Q2u{_!(U7vw8pD9sGYH>i^m7 z{}+n?Uupb*wdw!W=Kpu5|Gzi)|MMOH&*W4G3O9s`Hie5dhKhAYOSDHz^u$R`Ns&F; ztb4Lu|5%IOu~xma-9{(d4NrF&pY1liGsFJ=Y^MivoF6U?J>712zT5O-ui5SC4)>RKr8q1l%fEwzA2u%HJuE--ffHy7vt6B897@x85N6t6_|wh xC8YSdnANlNWmvcc#3Tf`S!Jfm>awvfU8*ZrFTHxr>XK5gjUk)2xH&Rd0|0YihcEyD literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/libs/Simulator.jar b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/libs/Simulator.jar new file mode 100644 index 0000000000000000000000000000000000000000..612bc7a0a73d888f36e046a1e079aaf70a4507be GIT binary patch literal 14656 zcmbVz1z26#4leE#_fm=!hvHD&-K}_WcMfjFU5mTByK8ZW;%>#=De_=u?zFel+c)p! ze4FpUVJ9d5PO_4$ENL-NFjOEYC@7$^P$(gw9|#o)3`jyio`*_AQt+(=kEDp8fSf$F zgy2Iz5YU;#;DERo74;ar7!~>O;7Fw`%@_KW&9zMsAZam3s0w$GL!2j8SWlPq-vWw$ z5Cy*wx(JD3+uNcJhlJ}GcACTg*mm3sg{im+l9q6Cj|F-n{%%nBer<4JJn3`f9f7M<&v@kB!sp1rJ9aw=bU_G@qR$ol_er0d0IrW& zMPD|M1tB8t*u4q1?iM_gzC_9kLeRqFdC#pxW(+m~Or(Zr1R+XR?#44VVq#h`c$!Oky4l9UN(3Y;=~k&e*|JexV1>#n=GkLJF#iXM*UgF)eqIz zX-0ArTMv0T225EQ>%FFk6IJzY{xHDC##Lw z9N^o-&l`u00I+y`yX4%4ZHQ|j>MJ(ku{tgUD;10AOyA=X^wRSuZp!A)Qclmq!EQR` z*345WvTdSw4)-{&5rPjfP2SR1=D=<8oee>{~^PdVQQ{<+K`R%6o)J>MY9GvzJsR3ArJW_ z^*8+-LTEB5v+u{R2Q2|oz~g6zpTcF!{TMnMl>;ODgfj13lWKcBS+lE5N5;;td`Xv1 z4mUhuSkiunBf{%#+KuINA?;xaKdwC5b--`drmGvlG!X$Kru3sIrK@&e}r_laLj^YcqD9Y2)%8sb?f)vp>kSMGOud=TPa=3SKc?$&)SIK>Cv3JGU>*Z#U_RS6BKZ zYowFSaa4@yU(b1?sDa#S6H`5>z? zBAZgs?woxcqLnTV5u{xy%9KkVz3P#qKQToqCCWt>u^WFL&%h>|Z0lxYMlBm}l&snX zY196dJ^5W(0zr~EsJ43Ub>69YYP(7g$Xthbe6#ytWbN12GvEpOnkmlbxor%)@ z-b7{fY%FZ8b@X@u0Ba*{Tfkq|87;3ag~Ef%QArh5G7#%>?V$q3H7A=NXs8VxK#Tl2 zFu?4V(`=efclJ%Asv$soXps@Lmnv;AR`^I`qf@a6Oo9v5(t76+(U z8mf1)b(+eiFfM=t3sS4zZnxP!GYzL^0mJHLfj+Yxy)dl!!2qH1W!5rTtI1(wu~OTK zUQy_R*-kCTd+vRxU~|$BU5Oz1F6sE;Zdg_7IAm(p;q7s4x(YXk=2vMuzP7Vplw%8d z#GK%<$Xz8pcO0YyKnf=xBb2o?+;T^IJ&Rrl(ui_62h`QO*p70CV7cYW8qRnRv(5 zL4Xp`m3XlSFr^})I>3nGiM{f@HG|F@J{Cg<)?38ADie=OM5~DMch!vh3SXH_V`Sl5 z;f=&Nzg6W#+F5VySznp7x8WkXUkS@nx`tgpUNbI3-b7}9b@*ipR;9tkAewv9#L(OO4DyHX7hD;6)y$W zOQ=xO;D`t+f<8%MVW=#T3GW=}tlFrYs49uKRX&^P;tAuDXX85zZ_QHYB=P2Usu1Ei ztLR<(0k^I_kgA&Y-GeKS55w;oS)DIkDDH1tkCws9a6@7Dz~Fi&m^ffjpEv)NFU8`I?3w9;BM$*0W{X&BUP^0Rce}!V6@Gg0%>L z9s}!Q5l6b5;kEAArsveX+@(tUO5I!Jasm)K1H&(PaFEv1p2ID*F7+ttDzdI2n*npc zdzQmw^-}mnDR8)>Fmq!I)frM_XJIoS@B_{~%%_9hLPbi3ELT%P_YsDsG&G#1`49JA z>8l?tsyC}TWLnYsn=LJAXtV`9jhXCbU}gat-()S~a#m|ITciOlq)c?YsUtR*LJoUX zMRg4=so5hIYP8xj%)7bOr+$J(lXktpi6pg6vRVnB-tv>o$WXj&aew>vV(inYa=GE5 zcg*c8rSS1=q+27Z57cSqa&OBHG6$lsdCONI5-=A(arcZdDr(C->eA81_8y}2?(Jiv z^g&8AGd=79-QcqL&sbGs0q)mZC-X z6)r9qqWcpBHfBh0k%yol$~qaSM6iB0JwyT)Rqz&E6^#nkTTDZ}B7-JFO^(cvlL`+e zLAG@ph&e1A%vd;6O;cT$_BKI5$n^@37pSLWst`=+a%q&|afvWPBa-6TnI{1osLd`Q z`F#%73@MUj3Yj>LGop1Bo7TD2W1ygtn^_tZW@sGRCqG-)(M7(I^BF4k5n{^M@- zEaRmBX>3L0rlkyDX!Q0+wxlXFn)MGup4yp_m4 z6UET=8W+eO=@rb5jpC$8jM9*CQedKJ&N+9S%{Xru$Ei@*k*I$#*kFg8-!FH8WZN$X zfowb|=Y@1WppEqs+Ak-71ig&QB7O^A9U?8AnVK=f^ReTgErZkwF`ee+XHxbTq0&*T zETS@BS6F-ih`FTpmYx|M?F<6hURZ(Tkd>&DFNUSRu=GlQVO2`Yv$2fHSZaRc{FCD4fTS6WoeE(5AroUd8Eg7^oTG&esEW# zsth61>{NvN8R8dd?_ajtSs}CWqqB7h>?2!f);d5U1mVmOF7;@fP!w#x%~w8gzg;a? z(wPyoAaKK|Z(yG2ygxnt3~K~*F5=5-w@RT_bZ&f0zBKj5>7(Gpn=Y=S6_bi=X3Z9O zuNP-dphp2*2{+SGr^JORnU|Q&Gb?-gnRTG`KA}RnF)G=hAN_!i z?!l~I(X8*GkZjr{w$k08pXmVR(l5t!xejCDRGMIQkiW^NZyP_QJyG0?v%f zCp(^3N66(bKmko*m)$_F0`TM01BeG$Z_T!~=Gr*t^a*DIgp9mXRbIUI_bNk5GsF7~ zhQ^JIJ`T11^2I6vK^=c{EK--k=R7z;D^NckpAZBZ-w$iF_$t$Syo=x$&9V|q z>ii_nWMl=6Wrd||g?6^aik|0^g8U){9d8Be1V050Z#C(fBL&61`)tjEC~+%Tz{0+`{0gf+P~xv(q#ED~*velbX;(uME|%9I z_MGPi%QXj$_rI?3`N%S;JsXLpkIogXY#=h7P(pZG3UK*oNaS`YgmrY56%oswCT4$B z-@NrTDYw@B;eiFB%=-y;!jOm>DYWm3u;$HSuWK>N+KzuXZO zJY5DY>C1(wG)u(w*TwkVJV{<`*lYf$`y~))UT~ca2P%^q20f>>gSb7~!rK}H0PGwK z8_Ga(qTtB7mCD689L_ltm85;THt!SVBLp;fLbW!cuJ6q?Z5al&Qt-`hTk4ljTlVQU zq*RLz_En10l#pL=%OW@H`T-R4QR6}mERP2Z z43{5xlcu!rlOl3q+zW`69-w@dHDk|+*pX(DvDU2OQ7u0OyN#S!Gu|LPo3T`dV*}tR zBhUM7MvnJ8GycKqQ25K!8ztME0iOIzcmg z12aPj^mO0RCwoW%vAO^sgCBeQ`MCk%by*%p@Au}9J6ZOLXE|>!+SrXOs_z`RKR7|G z5MyJ@g4m=ilRMWao6kGr_CT?>svQ+G!A%<~xA<1I_4Ran$k@TvDl9FynZ|pxT}M7S zX+@h-`V69Qsgndn80`i?mxh`~xmvw&YIeTn&ab;h2U=W#W5N>K*J8l+oCbG)&dh^i zGFGU9G~7g$XVS!q(6T&yMGo3sos#L4#b=sP9D2dw9bgD*AGB}{BBoU*E+!OOoKAow zBf$~)Q=9jWs-PxE*_=iXbNs{v?}c=!)5^TL2`zBC*$rfk(ZRPRkHsqg8NQjcsNr4e z=3@OxbI2G9dTfyNR7He*NzhwSs--Vh5Ef7y5+jS{s;Yuz6k!|n+~5_GpUKMTtY<*B z=K5sH!@+#VHtUMO+$0ej=o-eCgGn!vLI>jXVBydq2H16+aASuE$w3Ul#(ea}GWlOy z7QAWnZbsMPR44USu?3kYW1i_qG0tmPv<^vIuQWX(iK7fb?5#jvPYB&3h1rH9M<4Og zsX#FL7X1$MAif>?RJWB`fa!zPim5TWFPg>fW|kE_r8Y~b`QFQ>+8IqZJX`B<-wtt- zFM#cqymdYo{x{BtvOwncrnQck2F`V>I;=ID5J})3NAE)S1FA6xVRMJS8nX|DqU71M zI7SO@o5Y`G z7_pcuS@p(k>>e8pM&qT;N7S}$S^L(FA|jPFRaPTncB1B4E_~J0xfYD=BqoH0Q%)CE zS2VA~Tlk2eb^LM9xLJSTFqQL`wUwI83i^)4<8HvJD-2nK@vy%Mc8NZlE8^ZO2=%ln zw9wDSA>=&=!^*w4_0|^mhD+tqLRTN(7W+{f`?wM&5KD*=c-wmmFzL+fU~<)jqqY6+ zjw9D#=!-k*<`}F&4j+1)xwV)2^2EwXJ>Uc(6I%pJYYN&Uf-@f`SgCGA>0#B?3e?$P zmeSS<6Wp@f#L}(s*!?K#3P4845>Tn+9B__$M_5s%H%hV)x6l?9vjh~2?90nEB29Gy z%|!8Wsu<#jnUoVQEDBu{vgPW!FYk=6Zr)ym$xFge;%)-tZ3{YTW@p!y>of{ig6q>HFVC zVeWqi%im#HR?o}=p!Xku{sd++c3BQb0kx+!7HqtYm#kW$N(D`Y&j?4X9S>fc;u4ba zF8uY;z*nZ`o!56SW!#_q_;BBWnD=k<)8i}m@V)!ovfuE;n5g5b+-_-0Du zR?68sgOU2H({IZNZlIP(17rYbwNqQNJqi+4nau(d$d+N&l1Pn}YmGG5>1bBfyjGPM zJ+AP9inaIEgmS_#a7*RP`$ZYy-5M(O84TOoJ`RMYbELKsSYB4IF)b4^?$4Dv!7E?RGc1*jD6YdV@Zrv^i5L zIq=0exI)HeLC(;G6sb6uk&|ywC?jU-8A!gxZ0N~o&yD979N7^xaM=fyE+~)>dY7o* zw5x_Sx3E8cJ-Apf-yfWuN(9Oxu^o09Oud3lmk^zMldm)C)^quChkD8;R#OsOpFWvr ztpP5iu}76^FANf$q6(#z~oBrHVa;n0<@`)?w6Y z>y3s>X8Cf*)}W5mt&}}Gd33SKuNBu;%Xdcx zD;SkCO^1LbSd~}lQc7BS8U?qsyccIytZEl$pp4q?U>dgu3>G=g=g!C6ojB)n(a!v~ z%H37)@gCiA^4_6N@KmC6cI$bV%jMbJEo|uZZ&#AVna2eTK8h$HIcyQ7P@PgRHlsK&rnrZkiYTq#?cv)nJQ4@9cgPTh z`3_!TirDwEyIn3=TI1xx*%0WyBA_bk+fuhSlXa)qNC{SCur#0%+|vj6W|9_IC52RY z*sw_9D2Em&OtCBp@&e);r3RTrmtf=kH-l(SbqCqdPTeGsKRHsY;T|q^vlV~7y19$_ zu*rFQtS-!sQXCLa95)jfK-Cl`hF^|WLDDJnVj|eiZxLqplkV0kVx?rnJ*ZRu0A5FL ztj;Bcl+I&b^gVuRSnosle%RxiZwiXK&UQ6=gHAqk`!7Pxr6sN1sI!KwbQQCehf

8b=u5Ah)+M1mMdo~j-$iD|e;0y8g!BOa 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 - @@ -13,41 +13,44 @@ + id="oic.simulator.serviceprovider.category" + name="Service Provider"> - - - - + + @@ -60,21 +63,20 @@ + id="oic.simulator.serviceprovider.view.resourcemanager"> + id="oic.simulator.serviceprovider.view.attribute"> + id="oic.simulator.serviceprovider.view.orchestration"> + id="oic.simulator.serviceprovider.view.log"> - + - - + \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogContentProvider.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogContentProvider.java new file mode 100644 index 0000000..5d70e68 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogContentProvider.java @@ -0,0 +1,46 @@ +package oic.simulator.logger; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +public class LogContentProvider implements ITreeContentProvider { + + List logEntryList = new ArrayList(); + + @SuppressWarnings("unchecked") + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + logEntryList = (List) newInput; + } + + @Override + public Object[] getChildren(Object element) { + return new Object[0]; + } + + @Override + public Object[] getElements(Object input) { + return logEntryList.toArray(); + } + + @Override + public Object getParent(Object element) { + return null; + } + + @Override + public boolean hasChildren(Object element) { + return false; + } + + @Override + public void dispose() { + } + + public synchronized void addLog(LogEntry newElement) { + logEntryList.add(newElement); + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogEntry.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogEntry.java new file mode 100644 index 0000000..989a273 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogEntry.java @@ -0,0 +1,39 @@ +package oic.simulator.logger; + +import java.util.Date; + +import oic.simulator.serviceprovider.manager.LogManager; + +public class LogEntry { + private final int severity; + private final Date date; + private final String message; + + public LogEntry(int severity, Date date, String message) { + this.severity = severity; + this.date = date; + this.message = message; + } + + public String getMessage() { + return message; + } + + public Date getDate() { + return date; + } + + public int getSeverity() { + return severity; + } + + @Override + public String toString() { + String newline = System.getProperty("line.separator"); + String out = date.toString() + newline; + out += "Severity: " + LogManager.getSeverityName(severity) + newline; + out += "Message: " + message + newline; + out += "===============================" + newline + newline; + return out; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogLabelProvider.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogLabelProvider.java new file mode 100644 index 0000000..7ec2759 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogLabelProvider.java @@ -0,0 +1,38 @@ +package oic.simulator.logger; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +import oic.simulator.serviceprovider.manager.LogManager; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +public class LogLabelProvider extends LabelProvider implements + ITableLabelProvider { + + DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (columnIndex == 0) { + LogEntry entry = (LogEntry) element; + return LogManager.getSeverityIcon(entry.getSeverity()); + } + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + LogEntry entry = (LogEntry) element; + if (columnIndex == 0) { + return LogManager.getSeverityName(entry.getSeverity()); + } else if (columnIndex == 1) { + return dateFormat.format(entry.getDate()); + } else { + return entry.getMessage(); + } + } + +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LoggerCallback.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LoggerCallback.java new file mode 100644 index 0000000..94168e0 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LoggerCallback.java @@ -0,0 +1,55 @@ +package oic.simulator.logger; + +import java.util.Calendar; +import java.util.Date; + +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.utils.Constants; + +import org.oic.simulator.ILogger; + +public class LoggerCallback implements ILogger { + + @Override + public void write(String time, int level, String message) { + if (null == time || level < 0 || null == message) { + return; + } + // Parse the time + Date date = parseTime(time); + if (null == date) { + return; + } + Activator activator = Activator.getDefault(); + if (null == activator) { + return; + } + activator.getLogManager().log(level, date, message); + } + + private Date parseTime(String time) { + Date date; + String[] token = time.split("\\."); + int h, m, s; + try { + if (token.length == Constants.PROPER_LOG_TIME_TOKEN_LENGTH) { + h = Integer.parseInt(token[0]); + m = Integer.parseInt(token[1]); + s = Integer.parseInt(token[2]); + + Calendar calendar; + calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR, h); + calendar.set(Calendar.MINUTE, m); + calendar.set(Calendar.SECOND, s); + + date = calendar.getTime(); + } else { + date = null; + } + } catch (NumberFormatException nfe) { + date = null; + } + return date; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/Activator.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/Activator.java index 26c3043..c358680 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/Activator.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/Activator.java @@ -1,5 +1,6 @@ package oic.simulator.serviceprovider; +import oic.simulator.serviceprovider.manager.LogManager; import oic.simulator.serviceprovider.manager.ResourceManager; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -16,54 +17,53 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private static ResourceManager manager; + private static ResourceManager resourceManager; + + private static LogManager logManager; - /** - * The constructor - */ public Activator() { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ public void start(BundleContext context) throws Exception { super.start(context); plugin = this; - setManager(new ResourceManager()); + setResourceManager(new ResourceManager()); + setLogManager(new LogManager()); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ public void stop(BundleContext context) throws Exception { plugin = null; + + // Stopping Resource Manager + if (null != resourceManager) { + resourceManager.shutdown(); + resourceManager = null; + } + // Stopping Log Manager + if (null != logManager) { + logManager.shutdown(); + logManager = null; + } super.stop(context); } - /** - * Returns the shared instance - * - * @return the shared instance - */ public static Activator getDefault() { return plugin; } - public static ResourceManager getManager() { - return manager; + public ResourceManager getResourceManager() { + return resourceManager; } - public static void setManager(ResourceManager manager) { - Activator.manager = manager; + private static void setResourceManager(ResourceManager manager) { + Activator.resourceManager = manager; } -} + public LogManager getLogManager() { + return logManager; + } + + private static void setLogManager(LogManager logManager) { + Activator.logManager = logManager; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IAutomationUIListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IAutomationUIListener.java new file mode 100644 index 0000000..ecc2ee7 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IAutomationUIListener.java @@ -0,0 +1,7 @@ +package oic.simulator.serviceprovider.listener; + +public interface IAutomationUIListener { + public void onResourceAutomationStart(String resourceURI); + + public void onAutomationComplete(String resourceURI, String attName); +} diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/ILogUIListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/ILogUIListener.java new file mode 100644 index 0000000..dc539cd --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/ILogUIListener.java @@ -0,0 +1,11 @@ +package oic.simulator.serviceprovider.listener; + +import java.util.List; + +import oic.simulator.logger.LogEntry; + +public interface ILogUIListener { + public void logAdded(LogEntry added); + + public void logChanged(List entry); +} diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedListener.java deleted file mode 100644 index 3140ec1..0000000 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package oic.simulator.serviceprovider.listener; - -import java.util.List; - -public interface IResourceListChangedListener { - public void onResourceCreation(String resourceType, List resourceURI); - - public void onResourceDeletion(String resourceType, String resourceURI); - - public void onResourceDeletionByType(String resourceType); - - public void onAllResourceDeletion(); -} diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedUIListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedUIListener.java new file mode 100644 index 0000000..17ed87f --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedUIListener.java @@ -0,0 +1,7 @@ +package oic.simulator.serviceprovider.listener; + +public interface IResourceListChangedUIListener { + public void onResourceCreation(); + + public void onResourceDeletion(); +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceModelChangedUIListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceModelChangedUIListener.java new file mode 100644 index 0000000..7016df5 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceModelChangedUIListener.java @@ -0,0 +1,8 @@ +package oic.simulator.serviceprovider.listener; + +import oic.simulator.serviceprovider.resource.ModelChangeNotificationType; + +public interface IResourceModelChangedUIListener { + public void onResourceModelChange( + ModelChangeNotificationType notificationType, String resourceURI); +} diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceSelectionChangedUIListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceSelectionChangedUIListener.java new file mode 100644 index 0000000..4c844d6 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceSelectionChangedUIListener.java @@ -0,0 +1,5 @@ +package oic.simulator.serviceprovider.listener; + +public interface IResourceSelectionChangedUIListener { + public void onResourceSelectionChange(); +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/LogManager.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/LogManager.java new file mode 100644 index 0000000..8563ff0 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/LogManager.java @@ -0,0 +1,253 @@ +package oic.simulator.serviceprovider.manager; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; + +import oic.simulator.logger.LogEntry; +import oic.simulator.logger.LoggerCallback; +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.listener.ILogUIListener; +import oic.simulator.serviceprovider.utils.Constants; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.oic.simulator.ILogger; +import org.oic.simulator.ILogger.Level; +import org.oic.simulator.SimulatorManager; +import org.osgi.framework.Bundle; + +public class LogManager { + private LinkedList entries = new LinkedList(); + private ArrayList listeners = new ArrayList(); + private LinkedList visibleEntries = new LinkedList(); + private HashMap visibleSeverities = new HashMap(); + + private ILogger logger; + private LogManagerSynchronizerThread synchronizerThread; + private Thread threadHandle; + + static { + ImageRegistry r = Activator.getDefault().getImageRegistry(); + Bundle bundle = Activator.getDefault().getBundle(); + r.put(Constants.DEBUG_LOG, ImageDescriptor.createFromURL(bundle + .getEntry("/icons/debug_log.gif"))); + r.put(Constants.INFO_LOG, ImageDescriptor.createFromURL(bundle + .getEntry("/icons/info_log.gif"))); + r.put(Constants.WARNING_LOG, ImageDescriptor.createFromURL(bundle + .getEntry("/icons/warning_log.gif"))); + r.put(Constants.ERROR_LOG, ImageDescriptor.createFromURL(bundle + .getEntry("/icons/error_log.gif"))); + r.put(Constants.UNKNOWN_LOG, ImageDescriptor.createFromURL(bundle + .getEntry("/icons/unknown_log.gif"))); + } + + public LogManager() { + synchronizerThread = new LogManagerSynchronizerThread(); + threadHandle = new Thread(synchronizerThread); + threadHandle.setName("OIC Simulator event queue"); + threadHandle.start(); + + // Set the logger callback with the native layer + logger = new LoggerCallback(); + SimulatorManager.setLogger(logger); + } + + private static class LogManagerSynchronizerThread implements Runnable { + + LinkedList eventQueue = new LinkedList(); + + @Override + public void run() { + while (!Thread.interrupted()) { + + synchronized (this) { + try { + while (eventQueue.isEmpty()) { + this.wait(); + break; + } + } catch (InterruptedException e) { + return; + } + } + + Runnable pop; + synchronized (this) { + pop = eventQueue.pop(); + } + try { + pop.run(); + } catch (Exception e) { + if (e instanceof InterruptedException) { + return; + } + e.printStackTrace(); + } + } + } + + public void addToQueue(Runnable event) { + synchronized (this) { + eventQueue.add(event); + this.notify(); + } + } + } + + public void log(int severity, Date date, String msg) { + final LogEntry logEntry = new LogEntry(severity, date, msg); + synchronizerThread.addToQueue(new Runnable() { + @Override + public void run() { + boolean notify = false; + synchronized (entries) { + entries.add(logEntry); + Boolean showEntry = LogManager.this.visibleSeverities + .get(logEntry.getSeverity()); + if (showEntry != null) { + if (showEntry) { + visibleEntries.add(logEntry); + notify = true; + } + } + if (entries.size() > Constants.LOG_SIZE) { + entries.pop(); + } + if (visibleEntries.size() > Constants.LOG_SIZE) { + visibleEntries.pop(); + notify = true; + } + } + if (notify) { + notifyListeners(logEntry); + } + } + }); + } + + public void applyFilter(final HashMap visibleSeverities) { + synchronizerThread.addToQueue(new Runnable() { + + @Override + public void run() { + LinkedList newLogs = new LinkedList(); + synchronized (entries) { + LogManager.this.visibleSeverities = visibleSeverities; + for (LogEntry logEntry : entries) { + if (LogManager.this.visibleSeverities.get(logEntry + .getSeverity())) { + newLogs.add(logEntry); + } + } + } + visibleEntries = newLogs; + notifyListeners(); + } + }); + + } + + private void notifyListeners() { + for (ILogUIListener l : listeners) { + l.logChanged(new ArrayList(visibleEntries)); + } + } + + private void notifyListeners(LogEntry added) { + for (ILogUIListener l : listeners) { + l.logAdded(added); + } + } + + public void clearLog() { + synchronizerThread.addToQueue(new Runnable() { + + @Override + public void run() { + synchronized (entries) { + entries = new LinkedList(); + visibleEntries = new LinkedList(); + } + notifyListeners(); + } + }); + } + + public void removeEntry(final LogEntry element) { + synchronizerThread.addToQueue(new Runnable() { + + @Override + public void run() { + synchronized (entries) { + entries.remove(element); + visibleEntries.remove(element); + } + notifyListeners(); + } + }); + } + + public ArrayList getLogEntries() { + synchronized (entries) { + return new ArrayList(entries); + } + } + + public void addLogListener(final ILogUIListener listener) { + synchronizerThread.addToQueue(new Runnable() { + @Override + public void run() { + if (!listeners.contains(listener)) { + listeners.add(listener); + } + } + }); + } + + public void removeLogListener(final ILogUIListener listener) { + synchronizerThread.addToQueue(new Runnable() { + @Override + public void run() { + if (!listeners.contains(listener)) { + listeners.remove(listener); + } + } + }); + } + + public void shutdown() { + threadHandle.interrupt(); + } + + public static String getSeverityName(int severity) { + if (severity == Level.INFO.ordinal()) { + return Constants.INFO; + } else if (severity == Level.WARNING.ordinal()) { + return Constants.WARNING; + } else if (severity == Level.ERROR.ordinal()) { + return Constants.ERROR; + } else if (severity == Level.DEBUG.ordinal()) { + return Constants.DEBUG; + } else { + return Constants.UNKNOWN; + } + } + + public static Image getSeverityIcon(int severity) { + ImageRegistry r = Activator.getDefault().getImageRegistry(); + if (severity == Level.INFO.ordinal()) { + return r.get(Constants.INFO_LOG); + } else if (severity == Level.WARNING.ordinal()) { + return r.get(Constants.WARNING_LOG); + } else if (severity == Level.ERROR.ordinal()) { + return r.get(Constants.ERROR_LOG); + } else if (severity == Level.DEBUG.ordinal()) { + return r.get(Constants.DEBUG_LOG); + } else { + return r.get(Constants.UNKNOWN_LOG); + } + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java index 5f20998..9f4c4e5 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java @@ -1,23 +1,31 @@ package oic.simulator.serviceprovider.manager; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Vector; -import oic.simulator.serviceprovider.listener.IResourceListChangedListener; +import oic.simulator.serviceprovider.listener.IAutomationUIListener; +import oic.simulator.serviceprovider.listener.IResourceListChangedUIListener; +import oic.simulator.serviceprovider.listener.IResourceModelChangedUIListener; +import oic.simulator.serviceprovider.listener.IResourceSelectionChangedUIListener; +import oic.simulator.serviceprovider.resource.MetaProperty; +import oic.simulator.serviceprovider.resource.ModelChangeNotificationType; import oic.simulator.serviceprovider.resource.ResourceAttribute; import oic.simulator.serviceprovider.resource.SimulatorResource; import oic.simulator.serviceprovider.resource.StandardConfiguration; +import oic.simulator.serviceprovider.utils.Constants; -import org.iotivity.simulator.SimulatorManager; -import org.iotivity.simulator.SimulatorResourceAttribute; -import org.iotivity.simulator.SimulatorResourceModel; -import org.iotivity.simulator.SimulatorResourceServer; +import org.oic.simulator.AutomationType; +import org.oic.simulator.IAutomation; +import org.oic.simulator.SimulatorManager; +import org.oic.simulator.SimulatorResourceAttribute; +import org.oic.simulator.serviceprovider.IResourceModelChangedListener; +import org.oic.simulator.serviceprovider.SimulatorResourceModel; +import org.oic.simulator.serviceprovider.SimulatorResourceServer; public class ResourceManager { @@ -25,7 +33,23 @@ public class ResourceManager { private StandardConfiguration stdConfig; - private IResourceListChangedListener resourceListChangedListener; + private SimulatorResource currentResourceInSelection; + + private List resourceListChangedUIListeners; + + private List resourceSelectionChangedUIListeners; + + private List resourceModelChangedUIListeners; + + private List automationUIListeners; + + private IResourceModelChangedListener resourceModelChangeListener; + + private IAutomation automationListener; + + private NotificationSynchronizerThread synchronizerThread; + + private Thread threadHandle; static { System.loadLibrary("SimulatorManager"); @@ -35,22 +59,157 @@ public class ResourceManager { resourceMap = new HashMap>(); stdConfig = new StandardConfiguration(); + resourceListChangedUIListeners = new ArrayList(); + resourceSelectionChangedUIListeners = new ArrayList(); + resourceModelChangedUIListeners = new ArrayList(); + automationUIListeners = new ArrayList(); + // Populate standard configuration file list populateStandardConfigurationList(); + + resourceModelChangeListener = new IResourceModelChangedListener() { + + @Override + public void onResourceModelChanged(final String resourceURI, + final SimulatorResourceModel resourceModelN) { + synchronizerThread.addToQueue(new Runnable() { + + @Override + public void run() { + if (null == resourceURI || null == resourceModelN) { + return; + } + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null == resource) { + return; + } + // Fetch the resource attributes + Map resourceAttributeMapNew; + resourceAttributeMapNew = fetchResourceAttributesFromModel(resourceModelN); + if (null == resourceAttributeMapNew) { + return; + } + // Update the resource with new model data + Map resourceAttributeMapOld; + resourceAttributeMapOld = resource + .getResourceAttributesMap(); + if (null == resourceAttributeMapOld) { + return; + } + ModelChangeNotificationType notificationType; + notificationType = compareAndUpdateLocalAttributes( + resourceAttributeMapOld, + resourceAttributeMapNew); + if (notificationType != ModelChangeNotificationType.NONE) { + // Update the UI listeners + resourceModelChangedUINotification( + notificationType, resourceURI); + } + } + }); + } + }; + + automationListener = new IAutomation() { + + @Override + public void onAutomationComplete(final String resourceURI, + final int automationId) { + synchronizerThread.addToQueue(new Runnable() { + + @Override + public void run() { + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null == resource) { + return; + } + // Checking whether this notification is for an + // attribute or a resource + if (resource.isResourceAutomationInProgress()) { + changeResourceLevelAutomationStatus(resource, false); + // Notify the UI listeners + automationCompleteUINotification(resourceURI, null); + } else if (resource.isAttributeAutomationInProgress()) { + // Find the attribute with the given automation id + ResourceAttribute attribute; + attribute = getAttributeWithGivenAutomationId( + resource, automationId); + if (null != attribute) { + attribute.setAutomationInProgress(false); + resource.setAttributeAutomationInProgress(false); + // Notify the UI listeners + automationCompleteUINotification(resourceURI, + attribute.getAttributeName()); + } + } else { + // Ignoring the notification as there are no + // known automation for the current resource. + } + } + }); + } + }; + + synchronizerThread = new NotificationSynchronizerThread(); + threadHandle = new Thread(synchronizerThread); + threadHandle.setName("Simulator service provider event queue"); + threadHandle.start(); + } + + private static class NotificationSynchronizerThread implements Runnable { + + LinkedList notificationQueue = new LinkedList(); + + @Override + public void run() { + while (!Thread.interrupted()) { + synchronized (this) { + try { + while (notificationQueue.isEmpty()) { + this.wait(); + break; + } + } catch (InterruptedException e) { + return; + } + } + + Runnable thread; + synchronized (this) { + thread = notificationQueue.pop(); + } + try { + thread.run(); + } catch (Exception e) { + if (e instanceof InterruptedException) { + return; + } + e.printStackTrace(); + } + } + } + + public void addToQueue(Runnable event) { + synchronized (this) { + notificationQueue.add(event); + this.notify(); + } + } } - public void populateStandardConfigurationList() { + private void populateStandardConfigurationList() { // TODO: Add all the standard configuration files // Ex: stdConfig.addResourceConfiguration(LIGHT, LIGHT_FILE); } - public synchronized List getResourceConfigurationList() { + // This method gives a list of RAML resource configurations available. + public List getResourceConfigurationList() { List resourceConfigurationList = new ArrayList(); - Map configMap = stdConfig - .getStandardResourceConfigurationList(); - if (null != configMap) { - Set keySet = configMap.keySet(); - if (null != keySet) { + synchronized (stdConfig) { + Map configMap = stdConfig + .getStandardResourceConfigurationList(); + if (null != configMap) { + Set keySet = configMap.keySet(); Iterator keyItr = keySet.iterator(); while (keyItr.hasNext()) { resourceConfigurationList.add(keyItr.next()); @@ -60,58 +219,138 @@ public class ResourceManager { return resourceConfigurationList; } - public synchronized String getConfigFilePath(String resourceType) { + public String getConfigFilePath(String resourceType) { String path = null; if (null != resourceType) { - path = stdConfig.getResourceConfigFilePath(resourceType); + synchronized (stdConfig) { + path = stdConfig.getResourceConfigFilePath(resourceType); + } } return path; } - private synchronized void addResourceToMap( - SimulatorResource simulatorResource) { + public void addResourceListChangedUIListener( + IResourceListChangedUIListener resourceListChangedUIListener) { + synchronized (resourceListChangedUIListeners) { + resourceListChangedUIListeners.add(resourceListChangedUIListener); + } + } + + public void addResourceSelectionChangedUIListener( + IResourceSelectionChangedUIListener resourceSelectionChangedUIListener) { + synchronized (resourceSelectionChangedUIListeners) { + resourceSelectionChangedUIListeners + .add(resourceSelectionChangedUIListener); + } + } + + public void addResourceModelChangedUIListener( + IResourceModelChangedUIListener resourceModelChangedUIListener) { + synchronized (resourceModelChangedUIListeners) { + resourceModelChangedUIListeners.add(resourceModelChangedUIListener); + } + } + + public void addAutomationUIListener( + IAutomationUIListener automationUIListener) { + synchronized (automationUIListeners) { + automationUIListeners.add(automationUIListener); + } + } + + public void removeResourceListChangedUIListener( + IResourceListChangedUIListener listener) { + synchronized (resourceListChangedUIListeners) { + if (null != listener && resourceListChangedUIListeners.size() > 0) { + resourceListChangedUIListeners.remove(listener); + } + } + } + + public void removeResourceSelectionChangedUIListener( + IResourceSelectionChangedUIListener listener) { + synchronized (resourceSelectionChangedUIListeners) { + if (null != listener + && resourceSelectionChangedUIListeners.size() > 0) { + resourceSelectionChangedUIListeners.remove(listener); + } + } + } + + public void removeResourceModelChangedUIListener( + IResourceModelChangedUIListener listener) { + synchronized (resourceModelChangedUIListeners) { + if (null != listener && resourceModelChangedUIListeners.size() > 0) { + resourceModelChangedUIListeners.remove(listener); + } + } + } + + public void removeAutomationUIListener(IAutomationUIListener listener) { + synchronized (automationUIListeners) { + if (null != listener && automationUIListeners.size() > 0) { + automationUIListeners.remove(listener); + } + } + } + + public synchronized SimulatorResource getCurrentResourceInSelection() { + return currentResourceInSelection; + } + + public synchronized void setCurrentResourceInSelection( + SimulatorResource resource) { + this.currentResourceInSelection = resource; + } + + private void addResourceToMap(SimulatorResource simulatorResource) { if (null != simulatorResource) { - Map resourceTypeMap; - resourceTypeMap = resourceMap.get(simulatorResource - .getResourceType()); - if (null == resourceTypeMap) { - resourceTypeMap = new HashMap(); - resourceMap.put(simulatorResource.getResourceType(), - resourceTypeMap); + synchronized (resourceMap) { + Map resourceTypeMap; + resourceTypeMap = resourceMap.get(simulatorResource + .getResourceType()); + if (null == resourceTypeMap) { + resourceTypeMap = new HashMap(); + resourceMap.put(simulatorResource.getResourceType(), + resourceTypeMap); + } + resourceTypeMap.put(simulatorResource.getResourceURI(), + simulatorResource); } - resourceTypeMap.put(simulatorResource.getResourceURI(), - simulatorResource); } } - private synchronized void addResourceToMap(String resourceType, + private void addResourceToMap(String resourceType, Map newResourceTypeMap) { if (null != resourceType && null != newResourceTypeMap) { - Map resourceTypeMap = resourceMap - .get(resourceType); - if (null != resourceTypeMap) { - resourceTypeMap.putAll(newResourceTypeMap); - } else { - resourceMap.put(resourceType, newResourceTypeMap); + synchronized (resourceMap) { + Map resourceTypeMap = resourceMap + .get(resourceType); + if (null != resourceTypeMap) { + resourceTypeMap.putAll(newResourceTypeMap); + } else { + resourceMap.put(resourceType, newResourceTypeMap); + } } } } - private synchronized void removeResourceFromMap(String resourceType, - String resourceURI) { + private void removeResourceFromMap(String resourceType, String resourceURI) { if (null != resourceURI && null != resourceType) { - Map resourceTypeMap = resourceMap - .get(resourceType); - if (null != resourceTypeMap) { - resourceTypeMap.remove(resourceURI); - if (resourceTypeMap.size() < 1) { - resourceMap.remove(resourceType); + synchronized (resourceMap) { + Map resourceTypeMap = resourceMap + .get(resourceType); + if (null != resourceTypeMap) { + resourceTypeMap.remove(resourceURI); + if (resourceTypeMap.size() < 1) { + resourceMap.remove(resourceType); + } } } } } - public synchronized boolean isResourceExist(String resourceURI) { + public boolean isResourceExist(String resourceURI) { boolean result = false; if (null != resourceURI) { SimulatorResource resource = getSimulatorResourceByURI(resourceURI); @@ -122,55 +361,54 @@ public class ResourceManager { return result; } - public synchronized void createResource(String configFilePath) { - SimulatorResourceServer resourceServerN; - resourceServerN = SimulatorManager.createResource(configFilePath); + public void createResource(final String configFilePath) { + new Thread() { + @Override + public void run() { + SimulatorResourceServer resourceServerN; + resourceServerN = SimulatorManager.createResource( + configFilePath, resourceModelChangeListener); - SimulatorResource simulatorResource; - simulatorResource = fetchResourceData(resourceServerN); - if (null != simulatorResource) { - addResourceToMap(simulatorResource); - - String resourceType = simulatorResource.getResourceType(); - String resourceURI = simulatorResource.getResourceURI(); - List resourceURIList = new ArrayList(); - resourceURIList.add(resourceURI); - - resourceCreatedNotification(resourceType, resourceURIList); - } - } - - public synchronized void createResource(String configFilePath, - int noOfInstances) { - Map resourceTypeMap; - List resourceUriList; - Vector simulatorResourceServerVectorN = null; - simulatorResourceServerVectorN = SimulatorManager.createResource( - configFilePath, noOfInstances); - if (null != simulatorResourceServerVectorN) { - resourceTypeMap = new HashMap(); - resourceUriList = new ArrayList(); - Enumeration uriItr = simulatorResourceServerVectorN - .elements(); - SimulatorResourceServer resourceServerN; - SimulatorResource resource; - String uri; - while (uriItr.hasMoreElements()) { - resourceServerN = uriItr.nextElement(); - resource = fetchResourceData(resourceServerN); - if (null != resource) { - uri = resource.getResourceURI(); - resourceUriList.add(uri); - resourceTypeMap.put(uri, resource); - } - } - - // Find the resourceType and add it to the local data structure and - // notify UI Listeners - if (resourceTypeMap.size() > 0) { - String resourceType; - Set uriSet = resourceTypeMap.keySet(); - if (null != uriSet) { + SimulatorResource simulatorResource; + simulatorResource = fetchResourceData(resourceServerN); + if (null != simulatorResource) { + addResourceToMap(simulatorResource); + + resourceCreatedUINotification(); + } + } + }.start(); + } + + public void createResource(final String configFilePath, + final int noOfInstances) { + new Thread() { + @Override + public void run() { + Map resourceTypeMap; + SimulatorResourceServer[] simulatorResourceServers = null; + simulatorResourceServers = SimulatorManager.createResource( + configFilePath, noOfInstances, + resourceModelChangeListener); + if (null == simulatorResourceServers) { + return; + } + resourceTypeMap = new HashMap(); + SimulatorResource resource; + String uri; + for (SimulatorResourceServer resourceServerN : simulatorResourceServers) { + resource = fetchResourceData(resourceServerN); + if (null != resource) { + uri = resource.getResourceURI(); + resourceTypeMap.put(uri, resource); + } + } + + // Find the resourceType and add it to the local data + // structure and notify UI Listeners + if (resourceTypeMap.size() > 0) { + String resourceType; + Set uriSet = resourceTypeMap.keySet(); Iterator itr = uriSet.iterator(); if (itr.hasNext()) { SimulatorResource simResource = resourceTypeMap.get(itr @@ -179,23 +417,18 @@ public class ResourceManager { resourceType = simResource.getResourceType(); addResourceToMap(resourceType, resourceTypeMap); - - resourceCreatedNotification(resourceType, - resourceUriList); + resourceCreatedUINotification(); } } } } - } - + }.start(); } - private synchronized SimulatorResource fetchResourceData( + private SimulatorResource fetchResourceData( SimulatorResourceServer resourceServerN) { SimulatorResource simulatorResource = null; if (null != resourceServerN) { - Map resourceAttributeMap = null; - simulatorResource = new SimulatorResource(); simulatorResource.setResourceServer(resourceServerN); simulatorResource.setResourceURI(resourceServerN.getURI()); @@ -209,72 +442,122 @@ public class ResourceManager { if (null != resourceModelN) { simulatorResource.setResourceModel(resourceModelN); - Map attributeMapN; - attributeMapN = resourceModelN.getAttributes(); - if (null != attributeMapN) { - resourceAttributeMap = new HashMap(); - - Set attNameSet = attributeMapN.keySet(); - if (null != attNameSet) { - String attName; - SimulatorResourceAttribute attributeN; - ResourceAttribute attribute; - Iterator attNameItr = attNameSet.iterator(); - while (attNameItr.hasNext()) { - attName = attNameItr.next(); - attributeN = attributeMapN.get(attName); - if (null != attributeN) { - attribute = new ResourceAttribute(); - attribute.setAttributeName(attName); - - // Other attribute details such as value, - // allowed values and range are based on type - // Type implementation is yet to be done - resourceAttributeMap.put(attName, attribute); - } - } - simulatorResource - .setResourceAttributesMap(resourceAttributeMap); - } + // Fetch the resource attributes + Map resourceAttributeMap; + resourceAttributeMap = fetchResourceAttributesFromModel(resourceModelN); + if (null != resourceAttributeMap) { + simulatorResource + .setResourceAttributesMap(resourceAttributeMap); } } } return simulatorResource; } - private synchronized void resourceCreatedNotification(String resourceType, - List resourceURIList) { - if (null != resourceType && null != resourceURIList - && null != resourceListChangedListener) { - resourceListChangedListener.onResourceCreation(resourceType, - resourceURIList); + private Map fetchResourceAttributesFromModel( + SimulatorResourceModel resourceModelN) { + Map resourceAttributeMap = null; + if (null != resourceModelN) { + Map attributeMapN; + attributeMapN = resourceModelN.getAttributes(); + if (null != attributeMapN) { + resourceAttributeMap = new HashMap(); + + Set attNameSet = attributeMapN.keySet(); + String attName; + Object attValueObj; + SimulatorResourceAttribute attributeN; + ResourceAttribute attribute; + Iterator attNameItr = attNameSet.iterator(); + while (attNameItr.hasNext()) { + attName = attNameItr.next(); + attributeN = attributeMapN.get(attName); + if (null != attributeN) { + attribute = new ResourceAttribute(); + attribute.setResourceAttribute(attributeN); + attribute.setAttributeName(attName); + + attValueObj = attributeN.getValue(); + if (null != attValueObj) { + attribute.setAttributeValue(attValueObj); + } + + // Read allowed values or min-max values of the + // attribute + // TODO: Temporarily reading the allowed values + // as string + // If attribute type is known, then appropriate + // get method for that type will be called. + String[] allowedValues = resourceModelN + .getAllowedValues(attName); + attribute.setAllowedValues(allowedValues); + if (null == allowedValues || allowedValues.length < 1) { + // TODO: Get the range(min-max) of the attribute + // Implementation of GetRange is in progress + } + + // Initially disabling the automation + attribute.setAutomationInProgress(false); + + // TODO: Temporarily setting the interval to 500. + // This value should come from the native layer. + // Native implementation is in progress. + attribute + .setAutomationUpdateInterval(Constants.DEFAULT_AUTOMATION_INTERVAL); + + // Setting the default automation type + attribute + .setAutomationType(Constants.DEFAULT_AUTOMATION_TYPE); + + resourceAttributeMap.put(attName, attribute); + } + } + } } + return resourceAttributeMap; } - public synchronized void deleteResourceByURI(String resourceURI) { + public void deleteResourceByURI(final String resourceURI) { if (null != resourceURI) { - SimulatorResource resource = getSimulatorResourceByURI(resourceURI); - if (null != resource) { - String resourceType = resource.getResourceType(); + new Thread() { + @Override + public void run() { + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null != resource) { + String resourceType = resource.getResourceType(); - // Unregister the resource from the platform - deleteResource(resource); + // Unregister the resource from the platform + deleteResource(resource); - // Delete from the local data structure - deleteLocalResourceDetails(resourceType, resourceURI); + // Delete from the local data structure + deleteLocalResourceDetails(resourceType, resourceURI); - // Notify the UI listener for removing this resource from UI - resourceDeletedNotification(resourceType, resourceURI); - } + // Notify the UI listener for removing this resource + // from UI + resourceDeletedUINotification(); + + if (null != currentResourceInSelection + && resource == currentResourceInSelection) { + // Listeners might query the resource being deleted + // if exists. So set the currently selection to + // null. + setCurrentResourceInSelection(null); + + // Notify all observers for resource selection + // change event + resourceSelectionChangedUINotification(); + } + } + } + }.start(); } } - private synchronized SimulatorResource getSimulatorResourceByURI( - String resourceURI) { + private SimulatorResource getSimulatorResourceByURI(String resourceURI) { SimulatorResource resource = null; if (null != resourceURI) { - Set typeSet = resourceMap.keySet(); - if (null != typeSet) { + synchronized (resourceMap) { + Set typeSet = resourceMap.keySet(); Iterator typeItr = typeSet.iterator(); String resourceType; Map resourceTypeMap; @@ -293,7 +576,7 @@ public class ResourceManager { return resource; } - private synchronized void deleteResource(SimulatorResource resource) { + private void deleteResource(SimulatorResource resource) { if (null != resource) { SimulatorResourceServer resourceServerN = resource .getResourceServer(); @@ -303,92 +586,562 @@ public class ResourceManager { } } - public synchronized void deleteResourceByType(String resourceType) { + public void deleteResourceByType(final String resourceType) { if (null != resourceType) { - // Unregister the resources from the platform - deleteResource(resourceType); + new Thread() { + @Override + public void run() { + // Unregister the resources from the platform + deleteResource(resourceType); + + // Delete from the local data structure + deleteLocalResourceDetails(resourceType, null); - // Delete from the local data structure - deleteLocalResourceDetails(resourceType, null); + // Notify the UI listener for removing this resource from UI + resourceDeletedUINotification(); - // Notify the UI listener for removing this resource from UI - resourceTypeDeletedNotification(resourceType); + if (null != currentResourceInSelection + && resourceType.equals(currentResourceInSelection + .getResourceType())) { + // Listeners might query the resource being deleted if + // exists. So set the currently selection to null. + setCurrentResourceInSelection(null); + // Notify all observers for resource selection change + // event + resourceSelectionChangedUINotification(); + } + } + }.start(); } } - private synchronized void deleteResource(String resourceType) { + private void deleteResource(String resourceType) { if (null != resourceType) { SimulatorManager.deleteResources(resourceType); } } - public synchronized void deleteAllResources() { - // Unregister the resources from the platform - deleteResource(); + public void deleteAllResources() { + new Thread() { + @Override + public void run() { + // Unregister the resources from the platform + deleteResource(); - // Delete from the local data structure - deleteLocalResourceDetails(null, null); + // Delete from the local data structure + deleteLocalResourceDetails(null, null); + + // Notify the UI listener for removing this resource from UI + resourceDeletedUINotification(); + + // Listeners might query the resource being deleted if exists. + // So set the currently selection to null. + setCurrentResourceInSelection(null); - // Notify the UI listener for removing this resource from UI - allResourcesDeletedNotification(); + // Notify all observers for resource selection change event + resourceSelectionChangedUINotification(); + } + }.start(); } - private synchronized void deleteResource() { - // SimulatorManager.deleteResources(); + private void deleteResource() { + SimulatorManager.deleteResources(null); } - private synchronized void deleteLocalResourceDetails(String resourceType, + private void deleteLocalResourceDetails(String resourceType, String resourceURI) { if (null != resourceType && null != resourceURI) { removeResourceFromMap(resourceType, resourceURI); - } else if (null != resourceType) { - resourceMap.remove(resourceType); } else { - resourceMap.clear(); + synchronized (resourceMap) { + if (null != resourceType) { + resourceMap.remove(resourceType); + } else { + resourceMap.clear(); + } + } } } - private synchronized void resourceDeletedNotification(String resourceType, - String resourceURI) { - if (null != resourceListChangedListener) { - resourceListChangedListener.onResourceDeletion(resourceType, - resourceURI); + private void resourceCreatedUINotification() { + synchronized (resourceListChangedUIListeners) { + if (resourceListChangedUIListeners.size() > 0) { + IResourceListChangedUIListener listener; + Iterator listenerItr = resourceListChangedUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onResourceCreation(); + } + } + } } } - private synchronized void resourceTypeDeletedNotification( - String resourceType) { - if (null != resourceListChangedListener) { - resourceListChangedListener.onResourceDeletionByType(resourceType); + private void resourceDeletedUINotification() { + synchronized (resourceListChangedUIListeners) { + if (resourceListChangedUIListeners.size() > 0) { + IResourceListChangedUIListener listener; + Iterator listenerItr = resourceListChangedUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onResourceDeletion(); + } + } + } } } - private synchronized void allResourcesDeletedNotification() { - if (null != resourceListChangedListener) { - resourceListChangedListener.onAllResourceDeletion(); + private void resourceSelectionChangedUINotification() { + synchronized (resourceSelectionChangedUIListeners) { + if (resourceSelectionChangedUIListeners.size() > 0) { + IResourceSelectionChangedUIListener listener; + Iterator listenerItr = resourceSelectionChangedUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onResourceSelectionChange(); + } + } + } } } - public synchronized IResourceListChangedListener getResourceListChangedListener() { - return resourceListChangedListener; + private void resourceModelChangedUINotification( + ModelChangeNotificationType notificationType, String resourceURI) { + synchronized (resourceModelChangedUIListeners) { + if (resourceModelChangedUIListeners.size() > 0 + && notificationType != ModelChangeNotificationType.NONE + && null != resourceURI) { + IResourceModelChangedUIListener listener; + Iterator listenerItr = resourceModelChangedUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onResourceModelChange(notificationType, + resourceURI); + } + } + } + } } - public synchronized void setResourceListChangedListener( - IResourceListChangedListener resourceListChangedListener) { - this.resourceListChangedListener = resourceListChangedListener; + private void resourceAutomationStartedUINotification(String resourceURI) { + synchronized (automationUIListeners) { + if (automationUIListeners.size() > 0 && null != resourceURI) { + IAutomationUIListener listener; + Iterator listenerItr = automationUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onResourceAutomationStart(resourceURI); + } + } + } + } } - public synchronized List getResourceTypeList() { + private void automationCompleteUINotification(String resourceURI, + String attName) { + synchronized (automationUIListeners) { + if (automationUIListeners.size() > 0 && null != resourceURI) { + IAutomationUIListener listener; + Iterator listenerItr = automationUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onAutomationComplete(resourceURI, attName); + } + } + } + } + } + + public List getResourceTypeList() { List typeList = null; - if (null != resourceMap && resourceMap.size() > 0) { - typeList = new ArrayList(); - Set typeSet = resourceMap.keySet(); - Iterator typeItr = typeSet.iterator(); - while (typeItr.hasNext()) { - typeList.add(typeItr.next()); + synchronized (resourceMap) { + if (resourceMap.size() > 0) { + typeList = new ArrayList(); + Set typeSet = resourceMap.keySet(); + Iterator typeItr = typeSet.iterator(); + while (typeItr.hasNext()) { + typeList.add(typeItr.next()); + } } } return typeList; } -} + + public boolean isTypeExist(String resType) { + synchronized (resourceMap) { + if (resourceMap.containsKey(resType)) { + return true; + } + } + return false; + } + + public List getURIListOfResourceType(String type) { + List uriList = null; + synchronized (resourceMap) { + if (null != type) { + Map typeMap = resourceMap.get(type); + if (null != typeMap) { + Set keySet = typeMap.keySet(); + uriList = new ArrayList(); + Iterator keyItr = keySet.iterator(); + while (keyItr.hasNext()) { + uriList.add(keyItr.next()); + } + } + } + } + return uriList; + } + + public void resourceSelectionChanged(final String selectedItem) { + new Thread() { + @Override + public void run() { + // Check whether the item selected is a resource or resource + // category + if (isTypeExist(selectedItem)) { + // Given item is a resource Type + setCurrentResourceInSelection(null); + } else { + // Given item is a resource URI + SimulatorResource resource = getSimulatorResourceByURI(selectedItem); + if (null != resource) { + setCurrentResourceInSelection(resource); + } else { + setCurrentResourceInSelection(null); + } + } + // Notify all observers for resource selection change event + resourceSelectionChangedUINotification(); + } + }.start(); + } + + public List getMetaProperties(SimulatorResource resource) { + if (null != resource) { + String propName; + String propValue; + + List metaPropertyList = new ArrayList(); + + for (int index = 0; index < Constants.META_PROPERTY_COUNT; index++) { + propName = Constants.META_PROPERTIES[index]; + if (propName.equals(Constants.RESOURCE_URI)) { + propValue = resource.getResourceURI(); + } else if (propName.equals(Constants.RESOURCE_TYPE)) { + propValue = resource.getResourceType(); + } else if (propName.equals(Constants.RESOURCE_UID)) { + // propValue = resource.getResourceUID(); + propValue = "Dummy123"; // Temporarily adding dummy value to + // see in UI + } else if (propName.equals(Constants.CONNECTIVITY_TYPE)) { + // propValue = resource.getConnectivityType(); + propValue = "IP"; // Temporarily adding dummy value to see + // in UI + } else { + propValue = null; + } + if (null != propValue) { + metaPropertyList.add(new MetaProperty(propName, propValue)); + } + } + + return metaPropertyList; + } + return null; + } + + public List getAttributes(SimulatorResource resource) { + List attList = null; + if (null != resource) { + Map attMap = resource + .getResourceAttributesMap(); + if (null != attMap && attMap.size() > 0) { + attList = new ArrayList(); + Set attNameSet = attMap.keySet(); + String attName; + ResourceAttribute attribute; + // ResourceAttribute attributeClone; + Iterator attNameItr = attNameSet.iterator(); + while (attNameItr.hasNext()) { + attName = attNameItr.next(); + attribute = attMap.get(attName); + if (null != attribute) { + // attributeClone = + // ResourceAttribute.clone(attribute); + attList.add(attribute); + } + } + } + } + return attList; + } + + public void attributeValueUpdated(SimulatorResource resource, + String attributeName, String value) { + if (null != resource && null != attributeName && null != value) { + SimulatorResourceServer server = resource.getResourceServer(); + if (null != server) { + server.updateAttributeStringN(attributeName, value); + } + } + } + + private ModelChangeNotificationType compareAndUpdateLocalAttributes( + Map resourceAttributeMapOld, + Map resourceAttributeMapNew) { + ModelChangeNotificationType notificationType = ModelChangeNotificationType.NONE; + if (null != resourceAttributeMapOld && null != resourceAttributeMapNew) { + Set oldMapKeySet = resourceAttributeMapOld.keySet(); + Iterator attributeMapOldItr = oldMapKeySet.iterator(); + String attName; + ResourceAttribute attributeOld; + ResourceAttribute attributeNew; + Object attValueOld; + Object attValueNew; + String oldValueStr; + String newValueStr; + while (attributeMapOldItr.hasNext()) { + attName = attributeMapOldItr.next(); + if (resourceAttributeMapNew.containsKey(attName)) { + attributeOld = resourceAttributeMapOld.get(attName); + attributeNew = resourceAttributeMapNew.get(attName); + // Copy the attribute value from new to old if the value + // has been changed + // Comparing only the attribute's value considering the + // fact that only the value can be changed + if (null != attributeOld && null != attributeNew) { + attValueOld = attributeOld.getAttributeValue(); + attValueNew = attributeNew.getAttributeValue(); + + oldValueStr = String.valueOf(attValueOld); + newValueStr = String.valueOf(attValueNew); + + if (null != oldValueStr && null != newValueStr) { + if (!oldValueStr.equals(newValueStr)) { + attributeOld.setAttributeValue(attValueNew); + notificationType = ModelChangeNotificationType.ATTRIBUTE_VALUE_CHANGED; + } + } + } + resourceAttributeMapNew.remove(attName); + } else { + // Attribute doesn't exist in the new model. Hence + // removing it from the model. + resourceAttributeMapOld.remove(attName); + notificationType = ModelChangeNotificationType.ATTRIBUTE_REMOVED; + } + } + // Check for new attributes in the new model + if (resourceAttributeMapNew.size() > 0) { + Set remainingAttSet = resourceAttributeMapNew.keySet(); + Iterator remainingAttItr = remainingAttSet.iterator(); + ResourceAttribute attribute; + while (remainingAttItr.hasNext()) { + attName = remainingAttItr.next(); + if (null != attName) { + attribute = resourceAttributeMapNew.get(attName); + if (null != attribute) { + resourceAttributeMapOld.put(attName, attribute); + } + } + } + notificationType = ModelChangeNotificationType.ATTRIBUTE_ADDED; + } + } + return notificationType; + } + + public int startAutomation(SimulatorResource resource, + ResourceAttribute attribute, AutomationType autoType, + int autoUpdateInterval) { + int autoId = -1; + if (null != resource && null != attribute) { + SimulatorResourceServer resourceServerN = resource + .getResourceServer(); + if (null != resourceServerN) { + String attrName = attribute.getAttributeName(); + autoId = resourceServerN.startAttributeAutomation(attrName, + autoType.ordinal(), automationListener); + if (-1 != autoId) { + attribute.setAutomationId(autoId); + } else { + attribute.setAutomationInProgress(false); + resource.setAttributeAutomationInProgress(false); + } + } + } + return autoId; + } + + public void stopAutomation(SimulatorResource resource, int autoId) { + if (null != resource) { + SimulatorResourceServer resourceServerN = resource + .getResourceServer(); + if (null != resourceServerN) { + resourceServerN.stopAutomation(autoId); + } + } + } + + private ResourceAttribute getAttributeWithGivenAutomationId( + SimulatorResource resource, int automationId) { + ResourceAttribute targetAttribute = null; + if (null != resource) { + Map attributeMap = resource + .getResourceAttributesMap(); + if (null != attributeMap) { + Set attNameSet = attributeMap.keySet(); + Iterator attNameItr = attNameSet.iterator(); + String attName; + ResourceAttribute attribute; + while (attNameItr.hasNext()) { + attName = attNameItr.next(); + if (null != attName) { + attribute = attributeMap.get(attName); + if (null != attribute) { + if (attribute.isAutomationInProgress() + && (attribute.getAutomationId() == automationId)) { + targetAttribute = attribute; + break; + } + } + } + } + } + } + return targetAttribute; + } + + public boolean startResourceAutomationUIRequest(final String resourceURI) { + if (null == resourceURI) { + return false; + } + boolean status = false; + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null != resource) { + changeResourceLevelAutomationStatus(resource, true); + + // Invoke the native automation method + SimulatorResourceServer resourceServer = resource + .getResourceServer(); + if (null != resourceServer) { + // TODO: Temporarily handling the normal one-time automation for + // resources + int autoId = resourceServer.startResourceAutomation( + AutomationType.NORMAL.ordinal(), automationListener); + if (-1 == autoId) { + // Automation request failed and hence status is being + // rolled back + changeResourceLevelAutomationStatus(resource, false); + } else { + // Automation request accepted. + resource.setAutomationId(autoId); + + // Notify the UI listeners in a different thread. + Thread notifyThread = new Thread() { + public void run() { + resourceAutomationStartedUINotification(resourceURI); + }; + }; + notifyThread.setPriority(Thread.MAX_PRIORITY); + notifyThread.start(); + + status = true; + } + } + } + return status; + } + + public void stopResourceAutomationUIRequest(final String resourceURI) { + Thread stopThread = new Thread() { + public void run() { + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null == resource) { + return; + } + int autoId = resource.getAutomationId(); + if (-1 == autoId) { + return; + } + SimulatorResourceServer resourceServer = resource + .getResourceServer(); + if (null == resourceServer) { + return; + } + // Call native method + resourceServer.stopAutomation(autoId); + + // Invoke the automation complete callback + automationListener.onAutomationComplete(resourceURI, autoId); + } + }; + stopThread.start(); + } + + // Changes the automation state of the resource and its attributes + private void changeResourceLevelAutomationStatus( + SimulatorResource resource, boolean status) { + + Map attributeMap = resource + .getResourceAttributesMap(); + if (null != attributeMap) { + Set attrNameSet = attributeMap.keySet(); + Iterator attrNameItr = attrNameSet.iterator(); + String attrName; + ResourceAttribute attribute; + while (attrNameItr.hasNext()) { + attrName = attrNameItr.next(); + attribute = attributeMap.get(attrName); + if (null != attribute) { + attribute.setAutomationInProgress(status); + } + } + } + resource.setResourceAutomationInProgress(status); + } + + public boolean isResourceAutomationStarted(String resourceURI) { + boolean status = false; + if (null == resourceURI) { + return status; + } + + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null != resource) { + status = resource.isResourceAutomationInProgress(); + } + return status; + } + + public boolean isAttributeAutomationStarted(String resourceURI) { + boolean status = false; + if (null == resourceURI) { + return status; + } + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null != resource) { + status = resource.isAttributeAutomationInProgress(); + } + return status; + } + + public void shutdown() { + threadHandle.interrupt(); + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/perspective/PerspectiveFactory.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/perspective/PerspectiveFactory.java index 8c21587..cb8954e 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/perspective/PerspectiveFactory.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/perspective/PerspectiveFactory.java @@ -2,6 +2,7 @@ package oic.simulator.serviceprovider.perspective; import oic.simulator.serviceprovider.view.AttributeView; import oic.simulator.serviceprovider.view.LogView; +import oic.simulator.serviceprovider.view.MetaPropertiesView; import oic.simulator.serviceprovider.view.MultiResourceOrchestrationView; import oic.simulator.serviceprovider.view.ResourceManagerView; @@ -24,13 +25,13 @@ public class PerspectiveFactory implements IPerspectiveFactory { private void addViews() { factory.addView(ResourceManagerView.VIEW_ID, IPageLayout.LEFT, 0.3f, factory.getEditorArea()); - factory.addView(IPageLayout.ID_PROP_SHEET, IPageLayout.BOTTOM, 0.6f, + factory.addView(MetaPropertiesView.VIEW_ID, IPageLayout.BOTTOM, 0.65f, ResourceManagerView.VIEW_ID); - factory.addView(AttributeView.VIEW_ID, IPageLayout.LEFT, 0.5f, + factory.addView(AttributeView.VIEW_ID, IPageLayout.LEFT, 0.7f, factory.getEditorArea()); - factory.addView(LogView.VIEW_ID, IPageLayout.BOTTOM, 0.6f, + factory.addView(LogView.VIEW_ID, IPageLayout.BOTTOM, 0.65f, AttributeView.VIEW_ID); factory.addView(MultiResourceOrchestrationView.VIEW_ID, - IPageLayout.RIGHT, 0.5f, AttributeView.VIEW_ID); + IPageLayout.RIGHT, 0.6f, AttributeView.VIEW_ID); } -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AttributeValueType.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AttributeValueType.java index f6aeff5..5798035 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AttributeValueType.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AttributeValueType.java @@ -1,6 +1,6 @@ package oic.simulator.serviceprovider.resource; -// TODO: Temporarily adding this enum in plugin. It will be removed once it is added to the java api sdk +// TODO: Temporarily adding this enum in plug-in. It will be removed once it is added to the java api sdk public enum AttributeValueType { - INTEGER, DOUBLE, STRING, BOOLEAN, ENUMERATION -} + INTEGER, DOUBLE, STRING, BOOLEAN +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AutomationSettingHelper.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AutomationSettingHelper.java new file mode 100644 index 0000000..0d0d9eb --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AutomationSettingHelper.java @@ -0,0 +1,111 @@ +package oic.simulator.serviceprovider.resource; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import oic.simulator.serviceprovider.utils.Constants; + +import org.oic.simulator.AutomationType; + +public class AutomationSettingHelper { + private String settingID; + private String settingValue; + private List allowedValues; + + public String getSettingID() { + return settingID; + } + + public void setSettingID(String settingID) { + this.settingID = settingID; + } + + public String getSettingValue() { + return settingValue; + } + + public void setSettingValue(String settingValue) { + this.settingValue = settingValue; + } + + public List getAllowedValues() { + return allowedValues; + } + + public void setAllowedValues(List allowedValues) { + this.allowedValues = allowedValues; + } + + public void addAllowedValue(String newText) { + if (null != allowedValues) { + allowedValues.add(newText); + } + } + + public static List getAutomationSettings( + ResourceAttribute attribute) { + List settingList = null; + boolean invalidSetting; + if (null != attribute) { + settingList = new ArrayList(); + for (int count = 0; count < Constants.AUTOMATION_SETTINGS_COUNT; count++) { + invalidSetting = false; + AutomationSettingHelper setting = new AutomationSettingHelper(); + if (Constants.AUTOMATION_SETTINGS[count] + .equals(Constants.AUTOMATION)) { + setting.setSettingID(Constants.AUTOMATION); + setting.setSettingValue(attribute.isAutomationInProgress() ? Constants.ENABLE + : Constants.DISABLE); + List valueList = new ArrayList(); + valueList.add(Constants.ENABLE); + valueList.add(Constants.DISABLE); + setting.setAllowedValues(valueList); + } else if (Constants.AUTOMATION_SETTINGS[count] + .equals(Constants.AUTOMATION_TYPE)) { + setting.setSettingID(Constants.AUTOMATION_TYPE); + setting.setSettingValue(attribute.getAutomationType() + .toString()); + List valueList = new ArrayList(); + valueList.add(AutomationType.NORMAL.toString()); + valueList.add(AutomationType.RECURRENT.toString()); + setting.setAllowedValues(valueList); + } else if (Constants.AUTOMATION_SETTINGS[count] + .equals(Constants.UPDATE_INTERVAL_IN_MS)) { + setting.setSettingID(Constants.UPDATE_INTERVAL_IN_MS); + setting.setSettingValue(String.valueOf(attribute + .getAutomationUpdateInterval())); + List valueList = new ArrayList(); + for (int index = 1; index <= 10; index++) { + valueList.add(String.valueOf(index * 500)); + } + setting.setAllowedValues(valueList); + } else { + invalidSetting = true; + } + if (!invalidSetting) { + settingList.add(setting); + } + } + } + return settingList; + } + + public static void updateAutomationStatus( + List localSettingList, String status) { + if (null != localSettingList && null != status) { + Iterator settingItr = localSettingList + .iterator(); + AutomationSettingHelper setting; + while (settingItr.hasNext()) { + setting = settingItr.next(); + if (null != setting) { + if (setting.getSettingID().equals(Constants.AUTOMATION)) { + setting.setSettingValue(status); + break; + } + } + } + } + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/MetaProperty.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/MetaProperty.java new file mode 100644 index 0000000..bff71e7 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/MetaProperty.java @@ -0,0 +1,27 @@ +package oic.simulator.serviceprovider.resource; + +public class MetaProperty { + private String propName; + private String propValue; + + public MetaProperty(String propName, String propValue) { + this.propName = propName; + this.propValue = propValue; + } + + public String getPropValue() { + return propValue; + } + + public void setPropValue(String propValue) { + this.propValue = propValue; + } + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ModelChangeNotificationType.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ModelChangeNotificationType.java new file mode 100644 index 0000000..64deda9 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ModelChangeNotificationType.java @@ -0,0 +1,5 @@ +package oic.simulator.serviceprovider.resource; + +public enum ModelChangeNotificationType { + ATTRIBUTE_ADDED, ATTRIBUTE_REMOVED, ATTRIBUTE_VALUE_CHANGED, NONE +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ResourceAttribute.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ResourceAttribute.java index 979dcc0..02b0fab 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ResourceAttribute.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ResourceAttribute.java @@ -1,8 +1,13 @@ package oic.simulator.serviceprovider.resource; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Set; -import org.iotivity.simulator.SimulatorResourceAttribute; +import org.oic.simulator.AutomationType; +import org.oic.simulator.SimulatorResourceAttribute; public class ResourceAttribute { @@ -17,6 +22,14 @@ public class ResourceAttribute { private Object minValue; private Object maxValue; + private int automationId; + + private boolean automationInProgress; + + private int automationUpdateInterval; + + private AutomationType automationType; + public SimulatorResourceAttribute getResourceAttribute() { return resourceAttribute; } @@ -58,6 +71,17 @@ public class ResourceAttribute { this.allowedValues = allowedValues; } + public void setAllowedValues(String[] allowedValues) { + List allowedValueList = null; + if (null != allowedValues && allowedValues.length > 0) { + allowedValueList = new ArrayList(); + for (String value : allowedValues) { + allowedValueList.add(value); + } + } + this.allowedValues = allowedValueList; + } + public Object getMinValue() { return minValue; } @@ -73,4 +97,85 @@ public class ResourceAttribute { public void setMaxValue(Object maxValue) { this.maxValue = maxValue; } -} + + public boolean isAutomationInProgress() { + return automationInProgress; + } + + public void setAutomationInProgress(boolean automationInProgress) { + this.automationInProgress = automationInProgress; + } + + public int getAutomationUpdateInterval() { + return automationUpdateInterval; + } + + public void setAutomationUpdateInterval(int automationUpdateInterval) { + this.automationUpdateInterval = automationUpdateInterval; + } + + public AutomationType getAutomationType() { + return automationType; + } + + public void setAutomationType(AutomationType automationType) { + this.automationType = automationType; + } + + public int getAutomationId() { + return automationId; + } + + public void setAutomationId(int automationId) { + this.automationId = automationId; + } + + public static ResourceAttribute clone(ResourceAttribute attribute) { + ResourceAttribute clone = null; + if (null != attribute) { + clone = new ResourceAttribute(); + clone.setAttributeName(attribute.getAttributeName()); + clone.setAttributeValue(attribute.getAttributeValue()); + clone.setAllowedValues(attribute.getAllowedValues()); + clone.setAttributeType(attribute.getAttributeType()); + clone.setMinValue(attribute.getMinValue()); + clone.setMaxValue(attribute.getMaxValue()); + clone.setAutomationInProgress(attribute.isAutomationInProgress()); + clone.setAutomationType(attribute.getAutomationType()); + clone.setAutomationUpdateInterval(attribute + .getAutomationUpdateInterval()); + clone.setResourceAttribute(null); + } + return clone; + } + + // This method gives all known possible values of the attribute + // It takes allowed values or range of values whichever is available + public Set getValues() { + Set valueList = new HashSet(); + if (null != allowedValues) { + Iterator values = allowedValues.iterator(); + while (values.hasNext()) { + valueList.add(values.next()); + } + } else if (null != minValue && null != maxValue) { + if (attributeValue.getClass() == Integer.class) { + int min = (Integer) minValue; + int max = (Integer) maxValue; + for (int value = min; value <= max; value++) { + valueList.add(value); + } + } else if (attributeValue.getClass() == Double.class) { + double min = (Double) minValue; + double max = (Double) maxValue; + for (double value = min; value <= max; value++) { + valueList.add(value); + } + } + } + if (valueList.size() < 1) { + valueList.add(attributeValue); + } + return valueList; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/SimulatorResource.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/SimulatorResource.java index 5d383ff..f1f5171 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/SimulatorResource.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/SimulatorResource.java @@ -2,8 +2,9 @@ package oic.simulator.serviceprovider.resource; import java.util.Map; -import org.iotivity.simulator.SimulatorResourceModel; -import org.iotivity.simulator.SimulatorResourceServer; +import org.oic.simulator.AutomationType; +import org.oic.simulator.serviceprovider.SimulatorResourceModel; +import org.oic.simulator.serviceprovider.SimulatorResourceServer; public class SimulatorResource { private String resourceURI; @@ -11,11 +12,20 @@ public class SimulatorResource { private String resourceType; private String resourceInterface; - // Reference to objects created in native layer - // Native methods can be invoked using these object references + // Native Object references private SimulatorResourceServer resourceServer; private SimulatorResourceModel resourceModel; + private int automationId; + + private boolean resourceAutomationInProgress; + + private boolean attributeAutomationInProgress; + + private int automationUpdateInterval; + + private AutomationType automationType; + private Map resourceAttributesMap; public String getResourceURI() { @@ -75,4 +85,45 @@ public class SimulatorResource { this.resourceAttributesMap = resourceAttributesMap; } -} + public int getAutomationUpdateInterval() { + return automationUpdateInterval; + } + + public void setAutomationUpdateInterval(int automationUpdateInterval) { + this.automationUpdateInterval = automationUpdateInterval; + } + + public AutomationType getAutomationType() { + return automationType; + } + + public void setAutomationType(AutomationType automationType) { + this.automationType = automationType; + } + + public int getAutomationId() { + return automationId; + } + + public void setAutomationId(int automationId) { + this.automationId = automationId; + } + + public boolean isResourceAutomationInProgress() { + return resourceAutomationInProgress; + } + + public void setResourceAutomationInProgress( + boolean resourceAutomationInProgress) { + this.resourceAutomationInProgress = resourceAutomationInProgress; + } + + public boolean isAttributeAutomationInProgress() { + return attributeAutomationInProgress; + } + + public void setAttributeAutomationInProgress( + boolean attributeAutomationInProgress) { + this.attributeAutomationInProgress = attributeAutomationInProgress; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/StandardConfiguration.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/StandardConfiguration.java index d6e3333..2695713 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/StandardConfiguration.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/StandardConfiguration.java @@ -8,8 +8,7 @@ public class StandardConfiguration { private String configuration_directory_path; // A map of resourceType of standard resources as the key and the complete - // location of the file as - // the value + // location of the file as the value Map standardResourceConfigurationMap; public StandardConfiguration() { @@ -55,4 +54,4 @@ public class StandardConfiguration { standardResourceConfigurationMap.remove(resourceType); } } -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java index 1cf302d..14d0b5a 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java @@ -1,10 +1,72 @@ package oic.simulator.serviceprovider.utils; +import org.oic.simulator.AutomationType; + public class Constants { - public static final String UNDERSCORE = "_"; - public static final String FORWARD_SLASH = "/"; - public static final String OIC = "oic"; - public static final String SIMULATOR = "simulator"; + public static final String UNDERSCORE = "_"; + public static final String FORWARD_SLASH = "/"; + + public static final String OIC = "oic"; + public static final String SIMULATOR = "simulator"; + + public static final String RESOURCE_URI = "Resource URI"; + public static final String RESOURCE_TYPE = "Resource Type"; + public static final String RESOURCE_UID = "Resource ID"; + public static final String CONNECTIVITY_TYPE = "Connectivity Type"; + + public static final String[] META_PROPERTIES = { + RESOURCE_URI, RESOURCE_TYPE, RESOURCE_UID, CONNECTIVITY_TYPE }; + + public static final int META_PROPERTY_COUNT = META_PROPERTIES.length; + + public static final String ENABLE = "Enable"; + public static final String DISABLE = "Disable"; + public static final String ENABLED = "Enabled"; + public static final String DISABLED = "Disabled"; + + public static final String AUTOMATION = "Automation"; + public static final String AUTOMATION_TYPE = "Automation Type"; + public static final String UPDATE_INTERVAL_IN_MS = "Update Interval(ms)"; + + public static final String[] AUTOMATION_SETTINGS = { + AUTOMATION, AUTOMATION_TYPE, UPDATE_INTERVAL_IN_MS }; + + public static final int AUTOMATION_SETTINGS_COUNT = AUTOMATION_SETTINGS.length; + + public static final String START_RESOURCE_AUTOMATION = "Start Automation"; + public static final String STOP_RESOURCE_AUTOMATION = "Stop Automation"; + + public static final int PROPER_RESOURCE_URI_TOKEN_COUNT = 5; + public static final int DISPLAY_RESOURCE_URI_TOKEN_COUNT = 2; + + public static final AutomationType DEFAULT_AUTOMATION_TYPE = AutomationType.NORMAL; + + public static final int DEFAULT_AUTOMATION_INTERVAL = 500; + + public static final int PROPER_LOG_TIME_TOKEN_LENGTH = 3; + + public static final String[] BROWSE_RAML_FILTER_EXTENSIONS = new String[] { + "*.raml", "*" }; + public static final String[] SAVE_LOG_FILTER_EXTENSIONS = new String[] { + "*.log", "*" }; + + public static final int LOG_SIZE = 1000; + + public static final String INFO_LOG = "info_log"; + public static final String WARNING_LOG = "warning_log"; + public static final String ERROR_LOG = "error_log"; + public static final String DEBUG_LOG = "debug_log"; + public static final String UNKNOWN_LOG = "unknown_log"; + + public static final String INFO = "Info"; + public static final String WARNING = "Warning"; + public static final String ERROR = "Error"; + public static final String DEBUG = "Debug"; + public static final String UNKNOWN = "Unknown"; + + public static final String CREATE_PAGE_TITLE = "Create Resource"; + public static final String CREATE_PAGE_MESSAGE = "Select a standard resource or custom resource to be created"; - public static final int PROPER_RESOURCE_URI_TOKEN_COUNT = 5; -} + public static final String DELETE_PAGE_TITLE = "Delete Resource"; + public static final String DELETE_PAGE_MESSAGE = "Select the resource(s) to be deleted"; +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Convertion.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java similarity index 55% rename from service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Convertion.java rename to service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java index 644bb8b..481028a 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Convertion.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java @@ -1,13 +1,11 @@ package oic.simulator.serviceprovider.utils; -public class Convertion { +public class Utility { public static String uriToDisplayName(String uri) { String result = null; if (null != uri) { String tokens[] = uri.split(Constants.FORWARD_SLASH); - System.out.println(uri); - System.out.println(tokens.length); if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) { // Proper URI result = tokens[2] + Constants.UNDERSCORE + tokens[4]; @@ -20,7 +18,7 @@ public class Convertion { String result = null; if (null != displayName) { String tokens[] = displayName.split(Constants.UNDERSCORE); - if (2 == tokens.length) { + if (Constants.DISPLAY_RESOURCE_URI_TOKEN_COUNT == tokens.length) { // Proper Display Name result = Constants.FORWARD_SLASH + Constants.OIC + Constants.FORWARD_SLASH + tokens[0] @@ -35,12 +33,47 @@ public class Convertion { boolean uriComplete = false; if (null != uri) { String tokens[] = uri.split(Constants.FORWARD_SLASH); - System.out.println(uri); - System.out.println(tokens.length); if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) { uriComplete = true; } } return uriComplete; } -} + + public static String getAutomationStatus(boolean status) { + if (status) { + return Constants.ENABLED; + } else { + return Constants.DISABLED; + } + } + + public static String getAutomationString(boolean status) { + if (status) { + return Constants.ENABLE; + } else { + return Constants.DISABLE; + } + } + + public static boolean getAutomationBoolean(String status) { + if (null != status) { + if (status.equals(Constants.ENABLE)) { + return true; + } + } + return false; + } + + public static int getUpdateIntervalFromString(String value) { + int result = Constants.DEFAULT_AUTOMATION_INTERVAL; + if (null != value) { + try { + result = Integer.parseInt(value); + } catch (NumberFormatException nfe) { + // Do nothing + } + } + return result; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeView.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeView.java index 932fe27..ec47066 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeView.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeView.java @@ -1,22 +1,1030 @@ package oic.simulator.serviceprovider.view; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.listener.IAutomationUIListener; +import oic.simulator.serviceprovider.listener.IResourceModelChangedUIListener; +import oic.simulator.serviceprovider.listener.IResourceSelectionChangedUIListener; +import oic.simulator.serviceprovider.manager.ResourceManager; +import oic.simulator.serviceprovider.resource.AutomationSettingHelper; +import oic.simulator.serviceprovider.resource.ModelChangeNotificationType; +import oic.simulator.serviceprovider.resource.ResourceAttribute; +import oic.simulator.serviceprovider.resource.SimulatorResource; +import oic.simulator.serviceprovider.utils.Constants; +import oic.simulator.serviceprovider.utils.Utility; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ComboBoxCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StyledCellLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Point; +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.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; import org.eclipse.ui.part.ViewPart; +import org.oic.simulator.AutomationType; public class AttributeView extends ViewPart { - public static final String VIEW_ID = "oic.simulator.serviceprovider.view.attribute"; + public static final String VIEW_ID = "oic.simulator.serviceprovider.view.attribute"; + + private TableViewer attTblViewer; + private TableViewer automtnSettingsTblViewer; + + private IResourceSelectionChangedUIListener resourceSelectionChangedListener; + private IResourceModelChangedUIListener resourceModelChangedUIListener; + private IAutomationUIListener automationUIListener; + + private Label newValueLbl; + private CCombo valueCmb; + private Button submitButton; + private Button clearButton; + + private ResourceAttribute attributeInSelection; + private AttributeAutomationSettingEditor automationSettingEditor; + private List localSettingList; + + private final String[] attTblHeaders = { "Name", + "Value", "Automation Status" }; + private final String[] settingTblHeaders = { + "Setting", "Value" }; + private final Integer[] attTblColWidth = { 150, + 190, 150 }; + private final Integer[] settingTblColWidth = { 140, 85 }; + + private ResourceManager resourceManager; + + public AttributeView() { + + resourceManager = Activator.getDefault().getResourceManager(); + + resourceSelectionChangedListener = new IResourceSelectionChangedUIListener() { + + @Override + public void onResourceSelectionChange() { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (null != attTblViewer) { + updateViewer(checkSelection()); + } + } + }); + } + }; + + resourceModelChangedUIListener = new IResourceModelChangedUIListener() { + + @Override + public void onResourceModelChange( + final ModelChangeNotificationType notificationType, + final String resourceURI) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + // Handle the notification only if it is for the current + // resource in selection + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null == resource) { + return; + } + if (!resourceURI.equals(resource.getResourceURI())) { + return; + } + // Refresh the table viewers which will display + // the updated values + if (null != attTblViewer) { + attTblViewer.refresh(); + } + // If this call has a new value for the current + // attribute + // in selection, then update it in the combo box + if (notificationType != ModelChangeNotificationType.ATTRIBUTE_VALUE_CHANGED) { + return; + } + if (null != valueCmb && !valueCmb.isDisposed() + && null != attributeInSelection) { + Map attributeMap = resource + .getResourceAttributesMap(); + if (null != attributeMap) { + ResourceAttribute attribute = attributeMap + .get(attributeInSelection + .getAttributeName()); + if (null != attribute) { + Object valueObj = attribute + .getAttributeValue(); + if (null != valueObj) { + String valueStr = String + .valueOf(valueObj); + int index = valueCmb.indexOf(valueStr); + if (index != -1) { + valueCmb.select(index); + } else { + valueCmb.add(valueStr); + valueCmb.select(valueCmb + .indexOf(valueStr)); + } + } + } + } + } + } + }); + } + }; + + automationUIListener = new IAutomationUIListener() { + + @Override + public void onResourceAutomationStart(final String resourceURI) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (null == resourceURI) { + return; + } + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null == resource) { + return; + } + String uri = resource.getResourceURI(); + // Checking whether attributes view is currently + // displaying the attributes of the + // resource whose automation has just started + if (null != uri && uri.equals(resourceURI)) { + Table tbl; + tbl = attTblViewer.getTable(); + if (!tbl.isDisposed()) { + attTblViewer.refresh(); + } + + // If any attribute is in selection, then update + // the automation setting to enable. + if (null != attributeInSelection) { + tbl = automtnSettingsTblViewer.getTable(); + if (!tbl.isDisposed()) { + // Change the local automation settings + AutomationSettingHelper + .updateAutomationStatus( + localSettingList, + Constants.ENABLE); + automtnSettingsTblViewer.refresh(); + } + } + + // Disable the manual change UI controls + setVisibilityForManualValueChange(false); + } + } + }); + } + + @Override + public void onAutomationComplete(final String resourceURI, + final String attName) { + // This method notifies the completion of attribute level + // automation. + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (null == resourceURI) { + return; + } + // Check if the given resourceURI is the uri of the + // resource whose attributes are currently being + // displayed by this view. + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null == resource) { + return; + } + String uri = resource.getResourceURI(); + if (null != uri && uri.equals(resourceURI)) { + Table tbl; + tbl = attTblViewer.getTable(); + if (!tbl.isDisposed()) { + attTblViewer.refresh(); + } + + if (null != attributeInSelection) { + if (null == attName + || attributeInSelection + .getAttributeName().equals( + attName)) { + tbl = automtnSettingsTblViewer.getTable(); + if (!tbl.isDisposed()) { + // Change the local automation settings + AutomationSettingHelper + .updateAutomationStatus( + localSettingList, + Constants.DISABLE); + automtnSettingsTblViewer.refresh(); + } + setVisibilityForManualValueChange(true); + } + } + } + } + }); + } + }; + } + + @Override + public void createPartControl(Composite parent) { + Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE); + + parent.setLayout(new GridLayout(2, false)); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + parent.setLayoutData(gd); + + Group attGroup = new Group(parent, SWT.NONE); + attGroup.setLayout(new GridLayout(1, false)); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.horizontalSpan = 2; + gd.minimumHeight = 175; + attGroup.setLayoutData(gd); + attGroup.setText("Attributes"); + attGroup.setBackground(color); + + attTblViewer = new TableViewer(attGroup, SWT.MULTI | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); + + createAttributeColumns(attTblViewer); + + // make lines and header visible + Table table = attTblViewer.getTable(); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + attTblViewer.setContentProvider(new AttributeContentProvider()); + + Group automationSettingsTableGrp = new Group(parent, SWT.NONE); + automationSettingsTableGrp.setLayout(new GridLayout(1, false)); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + automationSettingsTableGrp.setLayoutData(gd); + automationSettingsTableGrp.setText("Automation Settings"); + automationSettingsTableGrp.setBackground(color); + + automtnSettingsTblViewer = new TableViewer(automationSettingsTableGrp, + SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION + | SWT.BORDER); + + createSettingColumns(automtnSettingsTblViewer); + + // make lines visible + table = automtnSettingsTblViewer.getTable(); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + table.setLayoutData(gd); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + automtnSettingsTblViewer + .setContentProvider(new AttributeContentProvider()); + + Composite rightViewComp = new Composite(parent, SWT.NONE); + rightViewComp.setLayout(new GridLayout(1, false)); + + Group valueUpdateGroup = new Group(rightViewComp, SWT.NONE); + valueUpdateGroup.setLayout(new GridLayout(2, false)); + gd = new GridData(); + gd.horizontalAlignment = SWT.FILL; + gd.grabExcessHorizontalSpace = true; + gd.horizontalSpan = 2; + valueUpdateGroup.setLayoutData(gd); + valueUpdateGroup.setText("Change Attribute Value"); + valueUpdateGroup.setBackground(color); + + newValueLbl = new Label(valueUpdateGroup, SWT.NONE); + newValueLbl.setText("Select New Value"); + + valueCmb = new CCombo(valueUpdateGroup, SWT.BORDER); + gd = new GridData(); + gd.widthHint = 100; + valueCmb.setLayoutData(gd); + + submitButton = new Button(rightViewComp, SWT.PUSH); + gd = new GridData(); + gd.widthHint = 150; + gd.verticalIndent = 10; + gd.horizontalSpan = 2; + gd.horizontalAlignment = SWT.CENTER; + submitButton.setLayoutData(gd); + submitButton.setText("Apply Changes"); + + clearButton = new Button(rightViewComp, SWT.PUSH); + gd = new GridData(); + gd.widthHint = 150; + gd.verticalIndent = 10; + gd.horizontalSpan = 2; + gd.horizontalAlignment = SWT.CENTER; + clearButton.setLayoutData(gd); + clearButton.setText("Reset Changes"); + + addUIListeners(); + + addManagerListeners(); + + // Check whether there is any resource selected already + List propertyList = checkSelection(); + if (null != propertyList) { + updateViewer(propertyList); + } + + setSettingSubmitVisibility(false); + } + + public void createAttributeColumns(TableViewer tableViewer) { + TableViewerColumn attName = new TableViewerColumn(tableViewer, SWT.NONE); + attName.getColumn().setWidth(attTblColWidth[0]); + attName.getColumn().setText(attTblHeaders[0]); + attName.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof ResourceAttribute) { + ResourceAttribute attribute = (ResourceAttribute) element; + if (null != attribute) { + return attribute.getAttributeName(); + } + } + return ""; + } + }); + + TableViewerColumn attValue = new TableViewerColumn(tableViewer, + SWT.NONE); + attValue.getColumn().setWidth(attTblColWidth[1]); + attValue.getColumn().setText(attTblHeaders[1]); + attValue.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof ResourceAttribute) { + ResourceAttribute attribute = (ResourceAttribute) element; + if (null != attribute) { + Object val = attribute.getAttributeValue(); + if (null != val) { + return String.valueOf(val); + } + } + } + return ""; + } + }); + + TableViewerColumn automationStatus = new TableViewerColumn(tableViewer, + SWT.NONE); + automationStatus.getColumn().setWidth(attTblColWidth[2]); + automationStatus.getColumn().setText(attTblHeaders[2]); + automationStatus.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof ResourceAttribute) { + ResourceAttribute attribute = (ResourceAttribute) element; + if (null != attribute) { + boolean progress = attribute.isAutomationInProgress(); + return Utility.getAutomationStatus(progress); + } + } + return ""; + } + }); + } + + public void createSettingColumns(TableViewer tableViewer) { + TableViewerColumn key = new TableViewerColumn(tableViewer, SWT.NONE); + key.getColumn().setWidth(settingTblColWidth[0]); + key.getColumn().setText(settingTblHeaders[0]); + key.setLabelProvider(new StyledCellLabelProvider() { + @Override + public void update(ViewerCell cell) { + Object element = cell.getElement(); + if (element instanceof AutomationSettingHelper) { + AutomationSettingHelper setting = (AutomationSettingHelper) element; + cell.setText(setting.getSettingID()); + } + } + }); + + TableViewerColumn value = new TableViewerColumn(tableViewer, SWT.NONE); + value.getColumn().setWidth(settingTblColWidth[1]); + value.getColumn().setText(settingTblHeaders[1]); + value.setLabelProvider(new CellLabelProvider() { + @Override + public void update(ViewerCell cell) { + Object element = cell.getElement(); + if (element instanceof AutomationSettingHelper) { + AutomationSettingHelper setting = (AutomationSettingHelper) element; + if (null != setting) { + cell.setText(String.valueOf(setting.getSettingValue())); + } + } + } + }); + automationSettingEditor = new AttributeAutomationSettingEditor( + tableViewer); + value.setEditingSupport(automationSettingEditor); + } + + private void addUIListeners() { + attTblViewer + .addSelectionChangedListener(new ISelectionChangedListener() { + + @Override + public void selectionChanged(SelectionChangedEvent e) { + IStructuredSelection selection = (IStructuredSelection) attTblViewer + .getSelection(); + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof ResourceAttribute) { + ResourceAttribute attribute = (ResourceAttribute) firstElement; + + // Store the attribute selection + attributeInSelection = attribute; + + // Change the visibility of the manual change + // controls according to the automation status + if (attribute.isAutomationInProgress()) { + setVisibilityForManualValueChange(false); + } else { + setVisibilityForManualValueChange(true); + } + + // Hide the visibility of submit and clear buttons + setSettingSubmitVisibility(false); + + if (null != attribute) { + if (null != automtnSettingsTblViewer) { + localSettingList = AutomationSettingHelper + .getAutomationSettings(attribute); + if (null != localSettingList) { + automtnSettingsTblViewer.getTable() + .setLinesVisible(true); + automtnSettingsTblViewer + .setInput(localSettingList + .toArray()); + } + } + // Populate the attribute value combo + if (null != valueCmb && !valueCmb.isDisposed()) { + // Clear the existing combo list contents + valueCmb.removeAll(); + Set valueList = attribute + .getValues(); + Object value; + if (null != valueList) { + Iterator valueItr = valueList + .iterator(); + while (valueItr.hasNext()) { + value = valueItr.next(); + if (null != value) { + // Casting the value to String + // for showing in combo + valueCmb.add(String + .valueOf(value)); + } + } + // Setting the selection to the current + // value of the attribute + String attValue = String + .valueOf(attribute + .getAttributeValue()); + int index = valueCmb.indexOf(attValue); + if (index != -1) { + valueCmb.select(index); + } + } + } + } + } + } + }); + + valueCmb.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (null != attributeInSelection) { + // attributeInSelection.setAttributeValue(valueCmb.getText()); + if (!valueCmb.getText().equals( + String.valueOf(attributeInSelection + .getAttributeValue()))) { + // Enable the submit and clear button controls + setSettingSubmitVisibility(true); + } else { + setSettingSubmitVisibility(false); + } + } + } + }); + + submitButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + if (null != attributeInSelection && null != localSettingList) { + if (attributeInSelection.isAutomationInProgress() + || valueCmb.getText().equals( + String.valueOf(attributeInSelection + .getAttributeValue()))) { + // Change in automation settings + Iterator settingItr = localSettingList + .iterator(); + + // These variables will hold the new automation + // settings. + boolean autoEnable = false; + AutomationType autoType = AutomationType.NORMAL; + int autoUpdateInterval = Constants.DEFAULT_AUTOMATION_INTERVAL; + + // These variables will hold the old automation settings + // and are used to roll-back the settings + // if automation fails. + boolean autoEnablePrev = false; + AutomationType autoTypePrev = AutomationType.NORMAL; + int autoUpdateIntervalPrev = Constants.DEFAULT_AUTOMATION_INTERVAL; + + String id; + String value; + AutomationSettingHelper setting; + while (settingItr.hasNext()) { + setting = settingItr.next(); + id = setting.getSettingID(); + value = setting.getSettingValue(); + if (id.equals(Constants.AUTOMATION)) { + autoEnable = Utility + .getAutomationBoolean(value); + autoEnablePrev = attributeInSelection + .isAutomationInProgress(); + + attributeInSelection + .setAutomationInProgress(autoEnable); + // Automation is disabled and hence the manual + // controls should be enabled + if (!autoEnable) { + setVisibilityForManualValueChange(true); + } + } else if (id.equals(Constants.AUTOMATION_TYPE)) { + autoType = AutomationType.valueOf(value); + autoTypePrev = attributeInSelection + .getAutomationType(); + + attributeInSelection + .setAutomationType(autoType); + } else if (id + .equals(Constants.UPDATE_INTERVAL_IN_MS)) { + autoUpdateInterval = Utility + .getUpdateIntervalFromString(value); + autoUpdateIntervalPrev = attributeInSelection + .getAutomationUpdateInterval(); + + attributeInSelection + .setAutomationUpdateInterval(autoUpdateInterval); + } + } + + // Updating the automation status in the resource + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + resource.setAttributeAutomationInProgress(autoEnable); + + if (autoEnable) { + // Send automation enable request + int autoId = resourceManager.startAutomation( + resource, attributeInSelection, autoType, + autoUpdateInterval); + if (-1 == autoId) { + // Automation failed + // Roll-back the attribute model and automation + // settings + settingItr = localSettingList.iterator(); + while (settingItr.hasNext()) { + setting = settingItr.next(); + id = setting.getSettingID(); + value = setting.getSettingValue(); + if (id.equals(Constants.AUTOMATION)) { + setting.setSettingValue(Utility + .getAutomationString(autoEnablePrev)); + } else if (id + .equals(Constants.AUTOMATION_TYPE)) { + setting.setSettingValue(autoTypePrev + .toString()); + } else if (id + .equals(Constants.UPDATE_INTERVAL_IN_MS)) { + setting.setSettingValue(String + .valueOf(autoUpdateIntervalPrev)); + } + } + + attributeInSelection + .setAutomationInProgress(autoEnablePrev); + attributeInSelection + .setAutomationType(autoTypePrev); + attributeInSelection + .setAutomationUpdateInterval(autoUpdateIntervalPrev); + + automtnSettingsTblViewer.refresh(); + + // Automation is disabled and hence the manual + // controls should be enabled + setVisibilityForManualValueChange(true); + } + } else { + // Send automation disable request + int autoId = attributeInSelection.getAutomationId(); + resourceManager.stopAutomation(resource, autoId); + } + } else { + // Change in attribute value manually + String input = valueCmb.getText(); + if (null != input && input.length() > 0) { + attributeInSelection.setAttributeValue(input); + + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + resourceManager.attributeValueUpdated(resource, + attributeInSelection.getAttributeName(), + input); + } + } + } + + attTblViewer.refresh(); + + setSettingSubmitVisibility(false); + } + }); + + clearButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (null != attributeInSelection) { + // Update the settings table + List settingList = AutomationSettingHelper + .getAutomationSettings(attributeInSelection); + if (null != settingList) { + // clear the existing table contents + Table tbl = automtnSettingsTblViewer.getTable(); + if (!tbl.isDisposed()) { + tbl.removeAll(); + localSettingList = settingList; + automtnSettingsTblViewer.setInput(localSettingList + .toArray()); + } + } + // Update the allowed values combo + if (!valueCmb.isDisposed()) { + valueCmb.setText(String.valueOf(attributeInSelection + .getAttributeValue())); + setVisibilityForManualValueChange(!attributeInSelection + .isAutomationInProgress()); + } + } + setSettingSubmitVisibility(false); + } + }); + } + + private void addManagerListeners() { + resourceManager + .addResourceSelectionChangedUIListener(resourceSelectionChangedListener); + resourceManager + .addResourceModelChangedUIListener(resourceModelChangedUIListener); + resourceManager.addAutomationUIListener(automationUIListener); + } + + private void setSettingSubmitVisibility(boolean visible) { + if (!submitButton.isDisposed()) + submitButton.setEnabled(visible); + if (!clearButton.isDisposed()) + clearButton.setEnabled(visible); + } + + private List checkSelection() { + SimulatorResource resourceInSelection = resourceManager + .getCurrentResourceInSelection(); + if (null != resourceInSelection) { + List attList = resourceManager + .getAttributes(resourceInSelection); + return attList; + } else { + return null; + } + } + + private void updateViewer(List attList) { + Table tbl; + if (null != attList) { + tbl = attTblViewer.getTable(); + if (null != tbl && !tbl.isDisposed()) { + tbl.setLinesVisible(true); + attTblViewer.setInput(attList.toArray()); + } + } else { + // Clear the attributes table viewer + if (null != attTblViewer) { + tbl = attTblViewer.getTable(); + if (null != tbl && !tbl.isDisposed()) { + // tbl.deselectAll(); + tbl.removeAll(); + tbl.setLinesVisible(false); + } + } + } + + attributeInSelection = null; + + // Clear the Settings table viewer + if (null != automtnSettingsTblViewer) { + tbl = automtnSettingsTblViewer.getTable(); + if (null != tbl && !tbl.isDisposed()) { + // tbl.deselectAll(); + tbl.removeAll(); + tbl.setLinesVisible(false); + } + } + // Clear the value list combo + if (!valueCmb.isDisposed()) { + valueCmb.removeAll(); + valueCmb.setEnabled(false); + } + + // Hide the visibility of submit and clear buttons + setSettingSubmitVisibility(false); + } + + class AttributeContentProvider implements IStructuredContentProvider { + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer arg0, Object arg1, Object arg2) { + } + + @Override + public Object[] getElements(Object element) { + return (Object[]) element; + } + + } + + class AttributeAutomationSettingEditor extends EditingSupport { + + private final TableViewer viewer; + + private AutomationSettingHelper currentSettingInSelection; + + public AttributeAutomationSettingEditor(TableViewer viewer) { + super(viewer); + this.viewer = viewer; + } + + @Override + protected boolean canEdit(Object element) { + return true; + } + + @Override + protected CellEditor getCellEditor(Object element) { + ComboBoxCellEditor combo = null; + if (null != element) { + List valueList; + boolean readOnly = true; + AutomationSettingHelper setting = (AutomationSettingHelper) element; + + currentSettingInSelection = setting; + + String settingID = setting.getSettingID(); + if (settingID.equals(Constants.UPDATE_INTERVAL_IN_MS)) { + readOnly = false; + } + valueList = setting.getAllowedValues(); + if (null == valueList) { + valueList = new ArrayList(); + } + // Convert list to String[] for passing it to ComboBoxCellEditor + String[] values; + values = valueList.toArray(new String[1]); + if (readOnly) { + combo = new ComboBoxCellEditor(viewer.getTable(), values, + SWT.READ_ONLY); + } else { + combo = new ComboBoxCellEditor(viewer.getTable(), values); + } + + // If resource level automation is enabled, then all setting + // should be disabled + SimulatorResource resourceInSelection; + resourceInSelection = resourceManager + .getCurrentResourceInSelection(); + if (null != resourceInSelection + && resourceInSelection.isResourceAutomationInProgress()) { + CCombo c = (CCombo) combo.getControl(); + c.setEnabled(false); + } else { + // Enable the automation type and update interval combo + // boxes only if the current value of automation is 'enable' + if (settingID.equals(Constants.AUTOMATION_TYPE) + || settingID + .equals(Constants.UPDATE_INTERVAL_IN_MS)) { + if (!showSettings()) { + // Disable the combo box + CCombo c = (CCombo) combo.getControl(); + c.setEnabled(false); + } + } + } + // Enabling editing support in update interval combo box + if (settingID.equals(Constants.UPDATE_INTERVAL_IN_MS)) { + final CCombo c = (CCombo) combo.getControl(); + c.addVerifyListener(new VerifyListener() { + @Override + public void verifyText(VerifyEvent e) { + String text = c.getText(); + String newText = text.substring(0, e.start) + + e.text + text.substring(e.end); + try { + if (newText.length() != 0) { + Integer.parseInt(newText); + } + } catch (NumberFormatException ex) { + e.doit = false; + } + } + }); + c.addTraverseListener(new TraverseListener() { + @Override + public void keyTraversed(TraverseEvent e) { + if (e.detail == SWT.TRAVERSE_RETURN) { + e.doit = false; + e.detail = SWT.TRAVERSE_NONE; + String newText = c.getText(); + try { + Integer.parseInt(newText); + if (null != currentSettingInSelection + && currentSettingInSelection + .getSettingID() + .equals(Constants.UPDATE_INTERVAL_IN_MS)) { + currentSettingInSelection + .addAllowedValue(newText); + } + c.add(newText); + c.setSelection(new Point(0, newText + .length())); + currentSettingInSelection + .setSettingValue(newText); + } catch (NumberFormatException ex) { + } + } + } + }); + } + } + + return combo; + } + + @Override + protected Object getValue(Object element) { + // This method returns the index of the item selected in the combo + // box + int index; + AutomationSettingHelper setting = (AutomationSettingHelper) element; + List itemList = setting.getAllowedValues(); + String currentValue = setting.getSettingValue(); + index = itemList.indexOf(currentValue); + return index; + } + + @Override + protected void setValue(Object element, Object value) { + AutomationSettingHelper setting = (AutomationSettingHelper) element; + int index = (Integer) value; + List valueList = setting.getAllowedValues(); + if (null != valueList) { + String targetValue; + if (index != -1) { + targetValue = valueList.get(index); + setting.setSettingValue(targetValue); + + if (setting.getSettingID().equals(Constants.AUTOMATION)) { + + if (attributeInSelection.isAutomationInProgress()) { + // settingsVisibility = false; + setVisibilityForManualValueChange(false); + } else { + if (targetValue.equals(Constants.ENABLE)) { + // settingsVisibility = true; + setVisibilityForManualValueChange(false); + } else { + // settingsVisibility = false; + setVisibilityForManualValueChange(true); + } + } + + // If status is changed, then enable the submit and + // clear buttons + if (!targetValue.equals(Utility + .getAutomationString(attributeInSelection + .isAutomationInProgress()))) { + setSettingSubmitVisibility(true); + } else { + setSettingSubmitVisibility(false); + } + } + } + } + viewer.refresh(); + } + } + + private boolean showSettings() { + boolean show = false; + if (!attributeInSelection.isAutomationInProgress()) { + AutomationSettingHelper setting; + Iterator list = localSettingList + .iterator(); + while (list.hasNext()) { + setting = list.next(); + if (setting.getSettingID().equals(Constants.AUTOMATION)) { + if (setting.getSettingValue().equals(Constants.ENABLE)) { + show = true; + } + break; + } + } + } + return show; + } + + // Disable the appropriate controls which are used for manual value change + private void setVisibilityForManualValueChange(boolean visibility) { + if (null != valueCmb && !valueCmb.isDisposed()) { + valueCmb.setEnabled(visibility); + } + if (null != newValueLbl && !newValueLbl.isDisposed()) { + newValueLbl.setEnabled(visibility); + } + } @Override - public void createPartControl(Composite arg0) { - // TODO Auto-generated method stub + public void dispose() { + // Unregister the selection listener + if (null != resourceSelectionChangedListener) { + resourceManager + .removeResourceSelectionChangedUIListener(resourceSelectionChangedListener); + } + // Unregister the model change listener + if (null != resourceModelChangedUIListener) { + resourceManager + .removeResourceModelChangedUIListener(resourceModelChangedUIListener); + } + + // Unregister the automation complete listener + if (null != automationUIListener) { + resourceManager.removeAutomationUIListener(automationUIListener); + } + + super.dispose(); } @Override public void setFocus() { - // TODO Auto-generated method stub } - -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogDetailsDialog.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogDetailsDialog.java new file mode 100644 index 0000000..c5d4e49 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogDetailsDialog.java @@ -0,0 +1,123 @@ +package oic.simulator.serviceprovider.view; + +import java.text.DateFormat; +import java.util.Date; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +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.layout.RowData; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class LogDetailsDialog extends Dialog { + private final String severity; + private final Date date; + private final String message; + private final Image severityIcon; + + public LogDetailsDialog(Shell parentShell, String severity, + Image severityIcon, Date date, String message) { + super(parentShell); + this.severity = severity; + this.severityIcon = severityIcon; + this.message = message; + this.date = date; + } + + @Override + protected boolean isResizable() { + return true; + } + + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + } + + @Override + protected Control createDialogArea(Composite parent) { + getShell().setText("Logged event details"); + + Composite container = (Composite) super.createDialogArea(parent); + + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + container.setLayoutData(layoutData); + container.setLayout(new GridLayout(2, false)); + + GridData gd; + + Label l1 = new Label(container, SWT.NONE); + l1.setText("Severity:"); + gd = new GridData(); + gd.widthHint = 100; + l1.setLayoutData(gd); + + Composite y = new Composite(container, SWT.NONE); + gd = new GridData(); + gd.grabExcessHorizontalSpace = true; + y.setLayoutData(gd); + y.setLayout(new RowLayout(SWT.HORIZONTAL)); + + Label l2 = new Label(y, SWT.NONE); + l2.setImage(severityIcon); + l2.setLayoutData(new RowData()); + Label l3 = new Label(y, SWT.NONE); + l3.setText(severity); + l3.setLayoutData(new RowData()); + + Label l4 = new Label(container, SWT.NONE); + l4.setText("Date:"); + gd = new GridData(); + gd.widthHint = 100; + l4.setLayoutData(gd); + + Label l5 = new Label(container, SWT.NONE); + DateFormat dateFormat = DateFormat.getDateTimeInstance( + DateFormat.SHORT, DateFormat.SHORT); + l5.setText(dateFormat.format(date)); + gd = new GridData(); + gd.grabExcessHorizontalSpace = true; + l5.setLayoutData(gd); + + new Label(container, SWT.NONE); // separator + + Label l6 = new Label(container, SWT.NONE); + l6.setText("Message details"); + gd = new GridData(); + gd.horizontalSpan = 2; + l6.setLayoutData(gd); + + Text text = new Text(container, SWT.MULTI | SWT.READ_ONLY + | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + if (message != null) { + text.setText(message); + } else { + text.setText("No description available"); + } + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.horizontalSpan = 2; + gd.heightHint = 350; + gd.widthHint = 500; + text.setLayoutData(gd); + + return container; + } + + @Override + protected Button createButton(Composite parent, int id, String label, + boolean defaultButton) { + if (id == IDialogConstants.CANCEL_ID) { + return null; + } + return super.createButton(parent, id, label, defaultButton); + } +} diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogView.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogView.java index 4615aa2..99af2ee 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogView.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogView.java @@ -1,22 +1,702 @@ package oic.simulator.serviceprovider.view; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.List; + +import oic.simulator.logger.LogContentProvider; +import oic.simulator.logger.LogEntry; +import oic.simulator.logger.LogLabelProvider; +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.listener.ILogUIListener; +import oic.simulator.serviceprovider.manager.LogManager; +import oic.simulator.serviceprovider.utils.Constants; +import oic.simulator.serviceprovider.view.dialogs.FilterDialog; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +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.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeColumn; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.part.ViewPart; +import org.oic.simulator.ILogger.Level; public class LogView extends ViewPart { - public static final String VIEW_ID = "oic.simulator.serviceprovider.view.log"; + public static final String VIEW_ID = "oic.simulator.serviceprovider.view.log"; + + private LogManager logManager; + private ILogUIListener logListener; + + private LogContentProvider treeContentProvider; + + private FilteredTree tree; + private TreeColumn severityColumn; + private TreeColumn dateColumn; + private TreeColumn messageColumn; + + private IAction exportLogAction; + private IAction clearLogAction; + private IAction deleteLogAction; + private IAction scrollLockAction; + private IAction logDetailsAction; + private IAction filterAction; + private IAction activateViewAction; + private IAction showTextFilter; + private IContributionItem groupByAction; + + private HashMap shownSeverities = new HashMap(); + + private boolean activateOnChange = false; + + private boolean hideTextFilter = false; + + private boolean scrollLockDisabled; + + public static final int ORDER_BY_TIME = 0; + public static final int ORDER_BY_SEVERITY = 1; + public static final int ORDER_BY_MESSAGE = 2; + + int sortCandidate = ORDER_BY_TIME; + + SortAction sortByTimeAction = new SortAction( + "Order by Time", + ORDER_BY_TIME); + SortAction sortBySeverityAction = new SortAction( + "Order by Severity", + ORDER_BY_SEVERITY); + SortAction sortByMessageAction = new SortAction( + "Order by Message", + ORDER_BY_MESSAGE); + + private ViewerComparator dateComparator; + private ViewerComparator severityComparator; + private ViewerComparator messageComparator; + + private TreeColumn sortColumn = null; + private static int DOWN = 1; + private static int UP = -1; + private int sortDirection = DOWN; + + public LogView() { + + logListener = new ILogUIListener() { + + @Override + public void logChanged(final List entry) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + TreeViewer viewer = tree.getViewer(); + if (viewer.getControl().isDisposed()) { + return; + } + viewer.setInput(entry); + updateTree(false); + } + }); + } + + @Override + public void logAdded(final LogEntry added) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + TreeViewer viewer = tree.getViewer(); + if (viewer.getControl().isDisposed()) { + return; + } + LogContentProvider provider = (LogContentProvider) viewer + .getContentProvider(); + provider.addLog(added); + tree.getViewer().add(viewer.getInput(), added); + @SuppressWarnings("unchecked") + List input = (List) viewer + .getInput(); + if (input.size() > Constants.LOG_SIZE) { + viewer.remove(viewer.getInput(), 0); + } + updateTree(true); + } + }); + } + + private void updateTree(boolean needscroll) { + if (activateOnChange) { + IWorkbenchPage page = Activator.getDefault().getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + if (page != null) { + page.bringToTop(LogView.this); + } + } + if (scrollLockDisabled && needscroll) { + Tree tree2 = tree.getViewer().getTree(); + if (tree2.getItemCount() > 0) { + TreeItem item = tree2.getItem(tree2.getItemCount() - 1); + tree2.setTopItem(item); + deleteLogAction.setEnabled(true); + } + } + } + }; + + logManager = Activator.getDefault().getLogManager(); + + // Initially state of scroll lock + scrollLockDisabled = true; + } @Override - public void createPartControl(Composite arg0) { - // TODO Auto-generated method stub + public void createPartControl(Composite parent) { + PatternFilter filter = new PatternFilter() { + + DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); + + @Override + protected boolean isLeafMatch(Viewer viewer, Object element) { + if (element instanceof LogEntry) { + LogEntry logEntry = (LogEntry) element; + String severity = LogManager.getSeverityName(logEntry + .getSeverity()); + String date = dateFormat.format(logEntry.getDate()); + String message = logEntry.getMessage(); + return wordMatches(severity) || wordMatches(date) + || wordMatches(message); + } + return false; + } + }; + filter.setIncludeLeadingWildcard(true); + tree = new FilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.FULL_SELECTION, filter, true); + + setupFilteredTree(); + + createColumnComparators(); + + createActions(); + + setDefaultShownSeverities(); + + IActionBars actionBars = getViewSite().getActionBars(); + IToolBarManager toolBarManager = actionBars.getToolBarManager(); + toolBarManager.add(exportLogAction); + toolBarManager.add(clearLogAction); + toolBarManager.add(deleteLogAction); + toolBarManager.add(scrollLockAction); + toolBarManager + .add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + + IMenuManager mgr = actionBars.getMenuManager(); + mgr.add(groupByAction); + mgr.add(new Separator()); + mgr.add(filterAction); + mgr.add(new Separator()); + mgr.add(activateViewAction); + mgr.add(showTextFilter); + + addManagerListeners(); + + if (sortCandidate == ORDER_BY_TIME) { + sortByTimeAction.run(); + } else if (sortCandidate == ORDER_BY_SEVERITY) { + sortBySeverityAction.run(); + } else { // order_selected == ORDER_BY_NONE + sortByMessageAction.run(); + } + + } + + private void setupFilteredTree() { + tree.setLayoutData(new GridData(GridData.FILL_BOTH)); + final Tree innerTree = tree.getViewer().getTree(); + innerTree.setLinesVisible(true); + + severityColumn = new TreeColumn(innerTree, SWT.LEFT); + severityColumn.setText("Severity"); + severityColumn.setWidth(110); + severityColumn.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + sortBySeverityAction.run(); + } + }); + dateColumn = new TreeColumn(innerTree, SWT.LEFT); + dateColumn.setText("Time"); + dateColumn.setWidth(110); + dateColumn.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + sortByTimeAction.run(); + } + }); + messageColumn = new TreeColumn(innerTree, SWT.LEFT); + messageColumn.setText("Message"); + messageColumn.setWidth(180); + messageColumn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + sortByMessageAction.run(); + } + }); + + innerTree.setHeaderVisible(true); + + treeContentProvider = new LogContentProvider(); + + tree.getViewer().setContentProvider(treeContentProvider); + tree.getViewer().setLabelProvider(new LogLabelProvider()); + + tree.getViewer().setInput(logManager.getLogEntries()); + + tree.getViewer().addSelectionChangedListener( + new ISelectionChangedListener() { + + @Override + public void selectionChanged(SelectionChangedEvent event) { + deleteLogAction.setEnabled(!tree.getViewer() + .getSelection().isEmpty()); + logDetailsAction.setEnabled(!tree.getViewer() + .getSelection().isEmpty()); + } + }); + + tree.getViewer().getTree().addKeyListener(new KeyListener() { + + @Override + public void keyReleased(KeyEvent e) { + } + + @Override + public void keyPressed(KeyEvent e) { + if (e.character == (char) 127) { // If delete key is pressed + if (deleteLogAction.isEnabled()) { + deleteLogAction.run(); + } + } + } + }); + + tree.getViewer().addDoubleClickListener(new IDoubleClickListener() { + + @Override + public void doubleClick(DoubleClickEvent event) { + logDetailsAction.run(); + } + }); + } + + private void createColumnComparators() { + dateComparator = new ViewerComparator() { + + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + LogEntry l1 = (LogEntry) e1; + LogEntry l2 = (LogEntry) e2; + return l1.getDate().compareTo(l2.getDate()) * sortDirection; + } + }; + + severityComparator = new ViewerComparator() { + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + LogEntry l1 = (LogEntry) e1; + LogEntry l2 = (LogEntry) e2; + if (l1.getSeverity() < l2.getSeverity()) { + return -1 * sortDirection; + } + if (l1.getSeverity() > l2.getSeverity()) { + return 1 * sortDirection; + } + return 0; + } + }; + + messageComparator = new ViewerComparator() { + + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + LogEntry l1 = (LogEntry) e1; + LogEntry l2 = (LogEntry) e2; + return l1.getMessage().compareTo(l2.getMessage()) + * sortDirection; + } + }; + + } + + private void setDefaultShownSeverities() { + shownSeverities.put(Level.INFO.ordinal(), true); + shownSeverities.put(Level.DEBUG.ordinal(), true); + shownSeverities.put(Level.WARNING.ordinal(), true); + shownSeverities.put(Level.ERROR.ordinal(), true); + } + + private void addManagerListeners() { + logManager.addLogListener(logListener); + logManager.applyFilter(shownSeverities); + } + + private void createActions() { + exportLogAction = createExportLogAction(); + clearLogAction = createClearLogAction(); + deleteLogAction = createDeleteLogAction(); + scrollLockAction = createScrollLockAction(); + logDetailsAction = createLogDetailsAction(); + + filterAction = createFilterAction(); + activateViewAction = createActivateViewAction(); + showTextFilter = createShowTextFilter(); + groupByAction = createGroupByAction(); + } + + private IAction createExportLogAction() { + Action action = new Action("Export log") { + @Override + public void run() { + FileDialog fd = new FileDialog(Display.getDefault() + .getActiveShell(), SWT.SAVE); + fd.setOverwrite(true); + fd.setFileName("OIC_Simulator_ServerLog.log"); + fd.setFilterExtensions(Constants.SAVE_LOG_FILTER_EXTENSIONS); + String name = fd.open(); + List logEntries = logManager.getLogEntries(); + StringBuilder sb = new StringBuilder(); + for (LogEntry entry : logEntries) { + sb.append(entry.toString()); + } + String data = sb.toString(); + BufferedWriter out = null; + try { + out = new BufferedWriter(new FileWriter(name)); + out.write(data); + } catch (IOException e) { + e.printStackTrace(); + MessageDialog.openError( + Display.getDefault().getActiveShell(), + "Export error", + "Could not export log. IO exception: " + + e.getMessage()); + } finally { + try { + out.close(); + } catch (IOException e) { + // Error occurred during close. Ignoring + } + } + } + }; + action.setToolTipText("Export log"); + + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/export_log_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/export_log_d.gif")); + action.setEnabled(true); + + return action; + } + + private IAction createClearLogAction() { + Action action = new Action("Clear log") { + + @Override + public void run() { + logManager.clearLog(); + } + }; + action.setToolTipText("Clear log"); + + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/clear_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/clear_d.gif")); + action.setEnabled(true); + return action; + } + + private IAction createDeleteLogAction() { + Action action = new Action("Delete log entry") { + + @Override + @SuppressWarnings("unchecked") + public void run() { + IStructuredSelection selection = (IStructuredSelection) tree + .getViewer().getSelection(); + List entries = (List) tree.getViewer() + .getInput(); + LogEntry selectedEntry = (LogEntry) selection.getFirstElement(); + if (null != selectedEntry) { + LogEntry toBeShownEntry = null; + for (LogEntry entry : entries) { + if (entry.equals(selectedEntry)) { + int size = entries.size(); + int index = entries.indexOf(selectedEntry); + if (index + 1 < size) { + toBeShownEntry = entries.get(index + 1); + } else if (index > 0) { + toBeShownEntry = entries.get(index - 1); + } + break; + } + } + logManager.removeEntry(selectedEntry); + if (null != toBeShownEntry) { + tree.getViewer().setSelection( + new StructuredSelection(toBeShownEntry)); + } + } + } + }; + action.setToolTipText("Delete log entry"); + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/delete_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/delete_d.gif")); + action.setEnabled(false); + return action; + } + + private IAction createScrollLockAction() { + Action action = new Action("Scroll lock") { + + @Override + public void run() { + scrollLockDisabled = !this.isChecked(); + }; + + @Override + public int getStyle() { + return IAction.AS_CHECK_BOX; + } + }; + action.setToolTipText("Scroll lock"); + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/lock_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/lock_d.gif")); + action.setEnabled(true); + return action; + } + + private IAction createLogDetailsAction() { + Action action = new Action("Details...") { + + @Override + public void run() { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + LogEntry x = (LogEntry) ((IStructuredSelection) tree + .getViewer().getSelection()).getFirstElement(); + + new LogDetailsDialog(Display.getDefault() + .getActiveShell(), LogManager.getSeverityName(x + .getSeverity()), LogManager.getSeverityIcon(x + .getSeverity()), x.getDate(), x.getMessage()) + .open(); + } + }); + } + }; + action.setToolTipText("Details..."); + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/log_details_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/log_details_e.gif")); + action.setEnabled(false); + return action; + } + + private IAction createFilterAction() { + Action action = new Action("Filters ...") { + + @Override + public void run() { + FilterDialog fd = new FilterDialog(Display.getDefault() + .getActiveShell(), shownSeverities); + if (fd.open() == Window.OK) { + logManager.applyFilter(shownSeverities); + } + tree.getViewer().refresh(); + } + }; + action.setToolTipText("Filters ..."); + + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/filter_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/filter_d.gif")); + action.setEnabled(true); + return action; + } + + private IAction createActivateViewAction() { + Action action = new Action("Activate view on new events", + IAction.AS_CHECK_BOX) { + + @Override + public void run() { + activateOnChange = this.isChecked(); + } + }; + action.setChecked(activateOnChange); + action.setToolTipText("Activate view on new events"); + + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/prop_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/prop_d.gif")); + action.setEnabled(true); + return action; + } + + private IAction createShowTextFilter() { + Action action = new Action("Show text filter", IAction.AS_CHECK_BOX) { + + @Override + public void run() { + Text filterControl = tree.getFilterControl(); + Composite filterComposite = filterControl.getParent(); + GridData gd = (GridData) filterComposite.getLayoutData(); + boolean visible = isChecked(); + gd.exclude = !visible; + filterComposite.setVisible(visible); + filterControl.setText(""); + if (visible) { + filterControl.selectAll(); + setFocus(); + } + tree.layout(false); + hideTextFilter = !visible; + } + }; + action.setToolTipText("Show text filter"); + + action.setImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/tree_mode_e.gif")); + action.setDisabledImageDescriptor(ImageDescriptor.createFromFile( + this.getClass(), "/icons/tree_mode_d.gif")); + action.setEnabled(true); + action.setChecked(!hideTextFilter); + if (hideTextFilter) { + action.run(); + } + return action; + } + + private IContributionItem createGroupByAction() { + IMenuManager manager = new MenuManager("Order by"); + manager.add(sortByTimeAction); + manager.add(sortBySeverityAction); + manager.add(sortByMessageAction); + return manager; + } + + class SortAction extends Action { + + private final int sortBy; + + public SortAction(String text, int sortBy) { + super(text, IAction.AS_RADIO_BUTTON); + this.sortBy = sortBy; + + if (sortCandidate == sortBy) { + setChecked(true); + } + } + + @Override + public void run() { + sortBySeverityAction.setChecked(false); + sortByTimeAction.setChecked(false); + sortCandidate = sortBy; + setChecked(true); + + ViewerComparator comparator; + TreeColumn column; + if (sortBy == ORDER_BY_SEVERITY) { + comparator = severityComparator; + column = severityColumn; + } else if (sortBy == ORDER_BY_TIME) { + comparator = dateComparator; + column = dateColumn; + } else { // Order by message + comparator = messageComparator; + column = messageColumn; + } + TreeViewer viewer = tree.getViewer(); + viewer.setComparator(comparator); + viewer.getTree().setSortColumn(column); + if (column.equals(sortColumn)) { // reverse sorting order + sortDirection = viewer.getTree().getSortDirection() == SWT.UP ? DOWN + : UP; + viewer.getTree().setSortDirection( + sortDirection == UP ? SWT.UP : SWT.DOWN); + viewer.refresh(); + } else { // set this column as the one to sort by + sortDirection = DOWN; + viewer.getTree().setSortDirection(SWT.DOWN); + } + sortColumn = column; + refresh(); + } + } + + private void refresh() { + tree.getViewer().refresh(); } @Override public void setFocus() { - // TODO Auto-generated method stub - + tree.setFocus(); } -} + @Override + public void dispose() { + logManager.removeLogListener(logListener); + super.dispose(); + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java new file mode 100644 index 0000000..936d17d --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java @@ -0,0 +1,185 @@ +package oic.simulator.serviceprovider.view; + +import java.util.List; + +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.listener.IResourceSelectionChangedUIListener; +import oic.simulator.serviceprovider.manager.ResourceManager; +import oic.simulator.serviceprovider.resource.MetaProperty; +import oic.simulator.serviceprovider.resource.SimulatorResource; + +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.ui.part.ViewPart; + +public class MetaPropertiesView extends ViewPart { + + public static final String VIEW_ID = "oic.simulator.serviceprovider.view.metaproperties"; + + private TableViewer tableViewer; + + private final String[] columnHeaders = { "Property", + "Value" }; + + private final Integer[] columnWidth = { 150, 150 }; + + private IResourceSelectionChangedUIListener resourceSelectionChangedListener; + + private ResourceManager resourceManager; + + public MetaPropertiesView() { + + resourceManager = Activator.getDefault().getResourceManager(); + + resourceSelectionChangedListener = new IResourceSelectionChangedUIListener() { + + @Override + public void onResourceSelectionChange() { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (null != tableViewer) { + updateViewer(checkSelection()); + } + } + }); + } + }; + } + + @Override + public void createPartControl(Composite parent) { + parent.setLayout(new GridLayout(1, false)); + + tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); + + createColumns(tableViewer); + + // make lines and header visible + final Table table = tableViewer.getTable(); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + tableViewer.setContentProvider(new PropertycontentProvider()); + + addManagerListeners(); + + // Check whether there is any resource selected already + List propertyList = checkSelection(); + if (null != propertyList) { + updateViewer(propertyList); + } + + } + + private List checkSelection() { + SimulatorResource resourceInSelection = resourceManager + .getCurrentResourceInSelection(); + if (null != resourceInSelection) { + List metaPropertyList = resourceManager + .getMetaProperties(resourceInSelection); + return metaPropertyList; + } else { + return null; + } + } + + private void updateViewer(List metaPropertyList) { + if (null != tableViewer) { + Table tbl = tableViewer.getTable(); + if (null != metaPropertyList) { + tableViewer.setInput(metaPropertyList.toArray()); + if (!tbl.isDisposed()) { + tbl.setLinesVisible(true); + } + } else { + if (!tbl.isDisposed()) { + tbl.removeAll(); + tbl.setLinesVisible(false); + } + } + } + } + + public void createColumns(TableViewer tableViewer) { + TableViewerColumn propName = new TableViewerColumn(tableViewer, + SWT.NONE); + propName.getColumn().setWidth(columnWidth[0]); + propName.getColumn().setText(columnHeaders[0]); + propName.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + MetaProperty prop = (MetaProperty) element; + if (null != prop) { + return prop.getPropName(); + } else { + return ""; + } + } + }); + + TableViewerColumn propValue = new TableViewerColumn(tableViewer, + SWT.NONE); + propValue.getColumn().setWidth(columnWidth[1]); + propValue.getColumn().setText(columnHeaders[1]); + propValue.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + MetaProperty prop = (MetaProperty) element; + if (null != prop) { + return prop.getPropValue(); + } else { + return ""; + } + } + }); + } + + private void addManagerListeners() { + resourceManager + .addResourceSelectionChangedUIListener(resourceSelectionChangedListener); + } + + class PropertycontentProvider implements IStructuredContentProvider { + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer arg0, Object arg1, Object arg2) { + } + + @Override + public Object[] getElements(Object element) { + return (Object[]) element; + } + + } + + @Override + public void dispose() { + // Unregister the listener + if (null != resourceSelectionChangedListener) { + resourceManager + .removeResourceSelectionChangedUIListener(resourceSelectionChangedListener); + } + super.dispose(); + } + + @Override + public void setFocus() { + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MultiResourceOrchestrationView.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MultiResourceOrchestrationView.java index b7832f2..99659a4 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MultiResourceOrchestrationView.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MultiResourceOrchestrationView.java @@ -9,14 +9,11 @@ public class MultiResourceOrchestrationView extends ViewPart { @Override public void createPartControl(Composite arg0) { - // TODO Auto-generated method stub - + // TODO: To be done } @Override public void setFocus() { - // TODO Auto-generated method stub - + // TODO To be done } - -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java index ecbb8e6..b620623 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java @@ -1,19 +1,27 @@ package oic.simulator.serviceprovider.view; -import java.util.Iterator; +import java.util.ArrayList; import java.util.List; import oic.simulator.serviceprovider.Activator; -import oic.simulator.serviceprovider.listener.IResourceListChangedListener; +import oic.simulator.serviceprovider.listener.IResourceListChangedUIListener; import oic.simulator.serviceprovider.manager.ResourceManager; -import oic.simulator.serviceprovider.utils.Convertion; +import oic.simulator.serviceprovider.utils.Constants; +import oic.simulator.serviceprovider.utils.Utility; import oic.simulator.serviceprovider.view.dialogs.CreateResourceWizard; import oic.simulator.serviceprovider.view.dialogs.DeleteCategory; import oic.simulator.serviceprovider.view.dialogs.DeleteResourceWizard; import oic.simulator.serviceprovider.view.dialogs.ResourceWizardDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MenuAdapter; +import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; @@ -23,118 +31,86 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.part.ViewPart; public class ResourceManagerView extends ViewPart { - public static final String VIEW_ID = "oic.simulator.serviceprovider.view.resourcemanager"; + public static final String VIEW_ID = "oic.simulator.serviceprovider.view.resourcemanager"; - private Button createButton; - private Button deleteButton; + private Button createButton; + private Button deleteButton; - private Tree resourceTreeHead; + private TreeViewer treeViewer; - private IResourceListChangedListener resourceListChangedListener; + private IResourceListChangedUIListener resourceListChangedListener; + + private ResourceManager resourceManager; public ResourceManagerView() { - resourceListChangedListener = new IResourceListChangedListener() { - @Override - public void onResourceCreation(String resourceType, - List resourceURI) { - if (null != resourceTreeHead - && !(resourceTreeHead.isDisposed()) - && null != resourceType && null != resourceURI) { - TreeItem resourceHead = null; - TreeItem[] items = resourceTreeHead.getItems(); - if (null != items) { - for (TreeItem item : items) { - if (item.getText().equals(resourceType)) { - resourceHead = item; - break; - } - } - if (null == resourceHead) { - // Adding a new tree header - resourceHead = new TreeItem(resourceTreeHead, - SWT.NULL); - resourceHead.setText(resourceType); - } - // Add resources under the resourceHead - Iterator uriItr = resourceURI.iterator(); - while (uriItr.hasNext()) { - TreeItem newItem = new TreeItem(resourceHead, - SWT.NULL); - newItem.setText(Convertion.uriToDisplayName(uriItr - .next())); - } - } - } - } + resourceManager = Activator.getDefault().getResourceManager(); + + resourceListChangedListener = new IResourceListChangedUIListener() { @Override - public void onResourceDeletion(String resourceType, - String resourceURI) { - if (null != resourceTreeHead - && !(resourceTreeHead.isDisposed())) { - TreeItem targetParent = null; - TreeItem[] headItems = resourceTreeHead.getItems(); - if (null != headItems) { - for (TreeItem item : headItems) { - if (item.getText().equals(resourceType)) { - targetParent = item; - break; - } - } - if (null != targetParent) { - TreeItem[] items = targetParent.getItems(); - for (TreeItem item : items) { - if (item.getText().equals( - Convertion - .uriToDisplayName(resourceURI))) { - item.dispose(); - if (targetParent.getItemCount() < 1) { - targetParent.dispose(); - } - break; - } - } + public void onResourceCreation() { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (null != treeViewer) { + treeViewer.refresh(); + treeViewer.expandAll(); } + + // Trigger the visibility of delete button + changeDeleteVisibility(); } - } + }); } @Override - public void onResourceDeletionByType(String resourceType) { - if (null != resourceTreeHead - && !(resourceTreeHead.isDisposed())) { - TreeItem items[] = resourceTreeHead.getItems(); - for (TreeItem item : items) { - if (item.getText().equals(resourceType)) { - item.dispose(); - break; - } - } - } - } + public void onResourceDeletion() { + Display.getDefault().asyncExec(new Runnable() { - public void onAllResourceDeletion() { - if (null != resourceTreeHead - && !(resourceTreeHead.isDisposed())) { - TreeItem[] items = resourceTreeHead.getItems(); - if (null != items) { - for (TreeItem item : items) { - item.dispose(); + @Override + public void run() { + if (null != treeViewer) { + treeViewer.refresh(); + treeViewer.expandAll(); } + + // Trigger the visibility of delete button + changeDeleteVisibility(); } - } + }); } }; } + public void changeDeleteVisibility() { + if (null == treeViewer) { + return; + } + boolean visibility; + Tree tree = treeViewer.getTree(); + if (null != tree && !tree.isDisposed() && tree.getItemCount() > 0) { + visibility = true; + } else { + visibility = false; + } + if (null != deleteButton && !deleteButton.isDisposed()) { + deleteButton.setEnabled(visibility); + } + } + @Override public void createPartControl(Composite parent) { Composite compContent = new Composite(parent, SWT.NONE); @@ -179,15 +155,23 @@ public class ResourceManagerView extends ViewPart { gd = new GridData(SWT.FILL, SWT.FILL, true, true); resourceGroup.setLayoutData(gd); - resourceTreeHead = new Tree(resourceGroup, SWT.SINGLE); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - - resourceTreeHead.setLayoutData(gd); + PatternFilter filter = new PatternFilter(); + FilteredTree filteredTree = new FilteredTree(resourceGroup, + SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE, filter, true); + treeViewer = filteredTree.getViewer(); + treeViewer.getTree().setLayoutData( + new GridData(SWT.FILL, SWT.FILL, true, true)); + treeViewer.setContentProvider(new TreeContentProvider()); + treeViewer.setLabelProvider(new TreeLabelProvider()); + treeViewer.setInput(new Object()); addUIListeners(); addManagerListeners(); + + // If there is at least one resource exist, then enable the delete + // resource button + changeDeleteVisibility(); } private void addUIListeners() { @@ -210,20 +194,13 @@ public class ResourceManagerView extends ViewPart { configFilePath = createWizard.getConfigFilePath(); count = createWizard.getResourceCount(); - // Create the resource - if (null != configFilePath - && configFilePath.length() > 0) { - if (count <= 1) { - // Single resource creation - // TODO: Temporary code to show the resource - // in UI - Activator.getManager().createResource( - configFilePath); - } else { - // Multi resource creation - // Activator.getDefault().getManager().createResource(configFilePath, - // count); - } + if (count <= 1) { + // Single resource creation + resourceManager.createResource(configFilePath); + } else { + // Multi-resource creation + resourceManager.createResource(configFilePath, + count); } } } @@ -244,69 +221,210 @@ public class ResourceManagerView extends ViewPart { .getActiveShell(), deleteWizard); int open = wizardDialog.open(); if (open == WizardDialog.OK) { - if (deleteWizard.getDeleteCategory() == DeleteCategory.BY_URI) { + DeleteCategory deleteCategory = deleteWizard + .getDeleteCategory(); + if (deleteCategory == DeleteCategory.BY_URI) { String uri = deleteWizard.getDeleteCandidate(); - boolean completeURI = Convertion + boolean completeURI = Utility .isUriComplete(uri); if (!completeURI) { - uri = Convertion.displayNameToUri(uri); + uri = Utility.displayNameToUri(uri); } - Activator.getManager().deleteResourceByURI(uri); - } else if (deleteWizard.getDeleteCategory() == DeleteCategory.BY_TYPE) { - Activator.getManager().deleteResourceByType( - deleteWizard.getDeleteCandidate()); - } else if (deleteWizard.getDeleteCategory() == DeleteCategory.ALL) { - Activator.getManager().deleteAllResources(); + resourceManager.deleteResourceByURI(uri); + } else if (deleteCategory == DeleteCategory.BY_TYPE) { + resourceManager + .deleteResourceByType(deleteWizard + .getDeleteCandidate()); + } else if (deleteCategory == DeleteCategory.ALL) { + resourceManager.deleteAllResources(); } } } - }); } }); - resourceTreeHead.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - TreeItem[] selectedItems = resourceTreeHead.getSelection(); - // Handling only single item selection events - if (1 == selectedItems.length) { - String selectedItem = selectedItems[0].getText(); - // Check whether the selected item is a resource category or - // a specific resource - boolean category = isSelectedTreeItemACategory(selectedItem); - if (!category) { - // TODO: Show the properties in the properties view + if (null != treeViewer) { + final Tree resourceTreeHead = treeViewer.getTree(); + if (null != resourceTreeHead) { + // Below code adds a listener to the tree for selection changes + // and notifies the resource manager + resourceTreeHead.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TreeItem selectedItem = (TreeItem) e.item; + if (null != selectedItem) { + String selectedItemText = selectedItem.getText(); + if (!isSelectedTreeItemACategory(selectedItemText)) { + selectedItemText = Utility + .displayNameToUri(selectedItemText); + } + // Propagate this selection change event to manager + resourceManager + .resourceSelectionChanged(selectedItemText); + } } - - } + }); + // Below code creates menu entries and shows them on right + // clicking a resource + final Menu menu = new Menu(resourceTreeHead); + resourceTreeHead.setMenu(menu); + menu.addMenuListener(new MenuAdapter() { + @Override + public void menuShown(MenuEvent e) { + // Clear existing menu items + MenuItem[] items = menu.getItems(); + for (int index = 0; index < items.length; index++) { + items[index].dispose(); + } + final String selectedItem = resourceTreeHead + .getSelection()[0].getText(); + if (isSelectedTreeItemACategory(selectedItem)) { + return; + } + MenuItem startItem = new MenuItem(menu, SWT.NONE); + startItem.setText(Constants.START_RESOURCE_AUTOMATION); + startItem.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + // Block starting resource level + // automation if any attribute level + // automation is in progress for the + // selected resource + boolean started = resourceManager.isAttributeAutomationStarted(Utility + .displayNameToUri(selectedItem)); + if (started) { + MessageDialog + .openInformation( + Display.getDefault() + .getActiveShell(), + "Attribute automation is in progress", + "Attribute level automation for this resource is already in progress!!!\nPlease stop all " + + "running attribute level automations to start resource level automation."); + } else { + boolean status = resourceManager + .startResourceAutomationUIRequest(Utility + .displayNameToUri(selectedItem)); + String statusMsg = status ? "Automation started successfully!!!" + : "Automation request failed!!!"; + MessageDialog.openInformation(Display + .getDefault().getActiveShell(), + "Automation Status", statusMsg); + } + } + }); + + MenuItem stopItem = new MenuItem(menu, SWT.NONE); + stopItem.setText(Constants.STOP_RESOURCE_AUTOMATION); + stopItem.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + resourceManager + .stopResourceAutomationUIRequest(Utility + .displayNameToUri(selectedItem)); + String statusMsg = "Automation stop requested!!!"; + MessageDialog.openInformation(Display + .getDefault().getActiveShell(), + "Automation Status", statusMsg); + } + }); + + // Set the initial visibility of menu items + boolean status = resourceManager + .isResourceAutomationStarted(Utility + .displayNameToUri(selectedItem)); + startItem.setEnabled(!status); + stopItem.setEnabled(status); + } + }); } - }); + } } private boolean isSelectedTreeItemACategory(String selectedItem) { boolean category = false; - TreeItem[] items = resourceTreeHead.getItems(); - if (null != items) { - for (TreeItem item : items) { - if (item.getText().equals(selectedItem)) { - category = true; - break; - } - } + if (null != selectedItem) { + category = resourceManager.isTypeExist(selectedItem); } return category; } public void addManagerListeners() { - ResourceManager manager = Activator.getManager(); - manager.setResourceListChangedListener(resourceListChangedListener); + resourceManager + .addResourceListChangedUIListener(resourceListChangedListener); } @Override public void setFocus() { - // TODO Auto-generated method stub + } + + @Override + public void dispose() { + // Unregister the listener + if (null != resourceListChangedListener) { + resourceManager + .removeResourceListChangedUIListener(resourceListChangedListener); + resourceManager.resourceSelectionChanged(null); + } + super.dispose(); + } +} + +class TreeContentProvider implements ITreeContentProvider { + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer arg0, Object arg1, Object arg2) { + } + @Override + public Object[] getChildren(Object parent) { + String resType = (String) parent; + List members; + members = Activator.getDefault().getResourceManager() + .getURIListOfResourceType(resType); + if (null == members) { + members = new ArrayList(); + } + return members.toArray(); + } + + @Override + public Object[] getElements(Object parent) { + List deptTypes; + deptTypes = Activator.getDefault().getResourceManager() + .getResourceTypeList(); + if (null == deptTypes) { + deptTypes = new ArrayList(); + } + return deptTypes.toArray(); } + @Override + public Object getParent(Object child) { + return null; + } + + @Override + public boolean hasChildren(Object parent) { + String resType = (String) parent; + if (Activator.getDefault().getResourceManager().isTypeExist(resType)) { + return true; + } + return false; + } } + +class TreeLabelProvider extends LabelProvider { + @Override + public String getText(Object element) { + String value = (String) element; + if (!Activator.getDefault().getResourceManager().isTypeExist(value)) { + value = Utility.uriToDisplayName(value); + } + return value; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourcePage.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourcePage.java index b2c23ba..345c0dd 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourcePage.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourcePage.java @@ -1,5 +1,7 @@ package oic.simulator.serviceprovider.view.dialogs; +import oic.simulator.serviceprovider.utils.Constants; + import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; @@ -44,8 +46,8 @@ public class CreateResourcePage extends WizardPage { @Override public void createControl(Composite parent) { setPageComplete(false); - setTitle("Create Resource"); - setMessage("Select a standard resource or custom resource to be created"); + setTitle(Constants.CREATE_PAGE_TITLE); + setMessage(Constants.CREATE_PAGE_MESSAGE); Composite compContent = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); compContent.setLayout(gridLayout); @@ -140,7 +142,7 @@ public class CreateResourcePage extends WizardPage { } private void populateDataInUI() { - // Populate Resourcetype in Combo + // Populate Resource-type in Combo populateResourceTypeCombo(); } @@ -211,6 +213,8 @@ public class CreateResourcePage extends WizardPage { public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(PlatformUI .getWorkbench().getDisplay().getActiveShell(), SWT.NONE); + fileDialog + .setFilterExtensions(Constants.BROWSE_RAML_FILTER_EXTENSIONS); String configFileAbsolutePath = fileDialog.open(); locationTxt.setText(configFileAbsolutePath); } @@ -265,7 +269,7 @@ public class CreateResourcePage extends WizardPage { }); } - public boolean isSelectionDone() { + private boolean isSelectionDone() { boolean done = false; try { resourceCount = Integer.parseInt(noOfInstancesText.getText()); @@ -277,7 +281,7 @@ public class CreateResourcePage extends WizardPage { } if (null != configFilePath && configFilePath.length() > 0 - && resourceCount >= 0) { + && resourceCount >= 1) { done = true; } return done; @@ -290,5 +294,4 @@ public class CreateResourcePage extends WizardPage { public int getResourceCount() { return resourceCount; } - -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java index 5d1e74f..5beab41 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java @@ -1,5 +1,13 @@ package oic.simulator.serviceprovider.view.dialogs; +import java.net.URL; + +import oic.simulator.serviceprovider.Activator; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.Wizard; public class CreateResourceWizard extends Wizard { @@ -8,6 +16,10 @@ public class CreateResourceWizard extends Wizard { public CreateResourceWizard() { setWindowTitle("Create resources"); + IPath path = new Path("/icons/oic_logo_64x64.png"); + URL find = FileLocator.find(Activator.getDefault().getBundle(), path, + null); + setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find)); } @Override @@ -28,5 +40,4 @@ public class CreateResourceWizard extends Wizard { public boolean performFinish() { return true; } - -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteCategory.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteCategory.java index c9cb692..ba2ff9d 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteCategory.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteCategory.java @@ -2,4 +2,4 @@ package oic.simulator.serviceprovider.view.dialogs; public enum DeleteCategory { ALL, BY_TYPE, BY_URI, NONE -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourcePage.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourcePage.java index bf1b32a..1272079 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourcePage.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourcePage.java @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.List; import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.utils.Constants; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; @@ -39,10 +40,9 @@ public class DeleteResourcePage extends WizardPage { @Override public void createControl(Composite parent) { - System.out.println("delete wizard open"); setPageComplete(false); - setTitle("Delete Resource"); - setMessage("Select the resource(s) to be deleted"); + setTitle(Constants.DELETE_PAGE_TITLE); + setMessage(Constants.DELETE_PAGE_MESSAGE); Composite compContent = new Composite(parent, SWT.NONE); compContent.setLayout(new GridLayout(1, false)); @@ -113,7 +113,8 @@ public class DeleteResourcePage extends WizardPage { private void populateResourceTypeCombo() { List resourceTypeList; - resourceTypeList = Activator.getManager().getResourceTypeList(); + resourceTypeList = Activator.getDefault().getResourceManager() + .getResourceTypeList(); if (null != resourceTypeList) { Iterator itr = resourceTypeList.iterator(); while (itr.hasNext()) { @@ -160,6 +161,7 @@ public class DeleteResourcePage extends WizardPage { public void widgetSelected(SelectionEvent e) { // Update the visibility of controls resourceUriTxt.setEnabled(true); + resourceUriTxt.setFocus(); resourceTypeCmb.setEnabled(false); deleteCategory = DeleteCategory.BY_URI; @@ -214,4 +216,4 @@ public class DeleteResourcePage extends WizardPage { public void setFocusToTextBox() { resourceUriTxt.setFocus(); } -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourceWizard.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourceWizard.java index 3d8fa0b..8b9a3b6 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourceWizard.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourceWizard.java @@ -1,9 +1,15 @@ package oic.simulator.serviceprovider.view.dialogs; +import java.net.URL; + import oic.simulator.serviceprovider.Activator; -import oic.simulator.serviceprovider.utils.Convertion; +import oic.simulator.serviceprovider.utils.Utility; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.Wizard; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; @@ -14,6 +20,10 @@ public class DeleteResourceWizard extends Wizard { public DeleteResourceWizard() { setWindowTitle("Delete resources"); + IPath path = new Path("/icons/oic_logo_64x64.png"); + URL find = FileLocator.find(Activator.getDefault().getBundle(), path, + null); + setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find)); } @Override @@ -29,11 +39,12 @@ public class DeleteResourceWizard extends Wizard { // Check whether the uri is in full form or short form // If it is in short form, expand it to its full form. String uri = page.getDeleteCandidate(); - boolean uriComplete = Convertion.isUriComplete(uri); + boolean uriComplete = Utility.isUriComplete(uri); if (!uriComplete) { - uri = Convertion.displayNameToUri(uri); + uri = Utility.displayNameToUri(uri); } - boolean exist = Activator.getManager().isResourceExist(uri); + boolean exist = Activator.getDefault().getResourceManager() + .isResourceExist(uri); if (!exist) { Shell activeShell = PlatformUI.getWorkbench().getDisplay() .getActiveShell(); @@ -56,4 +67,4 @@ public class DeleteResourceWizard extends Wizard { public String getDeleteCandidate() { return page.getDeleteCandidate(); } -} +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/FilterDialog.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/FilterDialog.java new file mode 100644 index 0000000..e0f4397 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/FilterDialog.java @@ -0,0 +1,75 @@ +package oic.simulator.serviceprovider.view.dialogs; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; + +import oic.simulator.serviceprovider.manager.LogManager; + +import org.eclipse.jface.dialogs.TrayDialog; +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.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; + +public class FilterDialog extends TrayDialog { + private Map severities; + + public FilterDialog(Shell shell, Map severities) { + super(shell); + this.severities = severities; + } + + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + createSeverityGroup(composite); + getShell().setText("Filter details"); + return composite; + } + + /** + * Dynamically creates a check-box list for severity levels for user to + * choose from + */ + private void createSeverityGroup(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout()); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 275; + group.setLayoutData(gd); + group.setText("Severity Levels"); + + ArrayList arrayList = new ArrayList( + severities.keySet()); + Collections.sort(arrayList); + for (final Integer i : arrayList) { + final Button checkbox = new Button(group, SWT.CHECK); + checkbox.setText(LogManager.getSeverityName(i)); + checkbox.setSelection(severities.get(i)); + checkbox.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + severities.put(i, checkbox.getSelection()); + } + }); + } + } + + @Override + public boolean isHelpAvailable() { + return false; + } +} \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/ResourceWizardDialog.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/ResourceWizardDialog.java index 0463020..59dd8e0 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/ResourceWizardDialog.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/ResourceWizardDialog.java @@ -31,5 +31,4 @@ public class ResourceWizardDialog extends WizardDialog { finishButton.setText(IDialogConstants.OK_LABEL); } } - -} +} \ No newline at end of file -- 2.7.4