From 87bdb306475e434f59a7832a3f242127ca2ba806 Mon Sep 17 00:00:00 2001 From: G S Senthil Kumar Date: Thu, 3 Sep 2015 15:30:41 +0530 Subject: [PATCH] Updating service provider plug-in with the following changes: 1. As per the review comments, - Implemented Resource Observer view with force notification feature. - Changed the Resources View from resource type based hierarchical listing to uncategorized ordered list. - Changed the Attributes View. 2. Added support for creating resources using standard configuration files available in plug-in. 3. Removed Simulator.jar and included instructions in README file. Change-Id: Ifd91a9c83fbaff934cffe0b1225bbf453ae3bd69 Signed-off-by: G S Senthil Kumar Reviewed-on: https://gerrit.iotivity.org/gerrit/2352 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../ServiceProviderPlugin/.classpath | 4 +- .../ServiceProviderPlugin/README.txt | 8 +- .../ServiceProviderPlugin/build.properties | 5 +- .../ServiceProviderPlugin/icons/button_free.PNG | Bin 0 -> 2389 bytes .../ServiceProviderPlugin/icons/button_pressed.PNG | Bin 0 -> 3136 bytes .../ServiceProviderPlugin/icons/checked.gif | Bin 0 -> 1627 bytes .../ServiceProviderPlugin/icons/light_16x16.png | Bin 0 -> 732 bytes .../ServiceProviderPlugin/icons/unchecked.gif | Bin 0 -> 1628 bytes .../ServiceProviderPlugin/libs/Simulator.jar | Bin 14656 -> 0 bytes .../ServiceProviderPlugin/plugin.xml | 10 + .../ServiceProviderPlugin/resource/light.raml | 80 ++ .../ServiceProviderPlugin/resource/oic.light.json | 21 + .../oic/simulator/serviceprovider/Activator.java | 14 + .../listener/IObserverListChangedUIListener.java | 5 + .../listener/IResourceModelChangedUIListener.java | 6 +- .../serviceprovider/manager/ResourceManager.java | 453 +++++++++--- .../perspective/PerspectiveFactory.java | 11 +- .../resource/AttributeValueType.java | 6 - .../resource/AutomationSettingHelper.java | 11 +- ...eAttribute.java => LocalResourceAttribute.java} | 103 ++- .../serviceprovider/resource/ObserverDetail.java | 25 + .../resource/SimulatorResource.java | 86 ++- .../resource/StandardConfiguration.java | 95 ++- .../simulator/serviceprovider/utils/Constants.java | 14 +- .../simulator/serviceprovider/utils/Utility.java | 53 ++ .../view/AttributeEditingSupport.java | 239 ++++++ .../serviceprovider/view/AttributeView.java | 822 +++------------------ .../simulator/serviceprovider/view/LogView.java | 1 + .../serviceprovider/view/MetaPropertiesView.java | 2 +- .../serviceprovider/view/ResourceManagerView.java | 57 +- .../serviceprovider/view/ResourceObserverView.java | 323 ++++++++ .../view/dialogs/AutomationSettingDialog.java | 151 ++++ .../view/dialogs/CreateResourcePage.java | 72 +- .../view/{ => dialogs}/LogDetailsDialog.java | 2 +- 34 files changed, 1674 insertions(+), 1005 deletions(-) create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/button_free.PNG create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/button_pressed.PNG create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/checked.gif create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/light_16x16.png create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/unchecked.gif delete mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/libs/Simulator.jar create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IObserverListChangedUIListener.java delete mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AttributeValueType.java rename service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/{ResourceAttribute.java => LocalResourceAttribute.java} (59%) create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ObserverDetail.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeEditingSupport.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceObserverView.java create mode 100644 service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/AutomationSettingDialog.java rename service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/{ => dialogs}/LogDetailsDialog.java (98%) diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath index 61b8255..ad84a71 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/README.txt b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt index bb5b937..39dc7af 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt @@ -7,6 +7,12 @@ Pre-requisites 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 + 3.Import the Simulator Java SDK project from ~/iotivity/service/simulator/java/sdk/ 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. + Export the sdk project as JAR file. + Right click the project -> Export -> select 'JAR file' option under Java -> Next -> Finish. + Copy the JAR file into the libs folder of the plug-in project. Steps to run the plug-in ------------------------ @@ -17,4 +23,4 @@ Steps to run the plug-in 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 + 3.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 0a482ed..b522aba 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties @@ -2,8 +2,7 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - libs/,\ icons/,\ plugin.xml,\ - ,\ - libs/Simulator.jar \ No newline at end of file + libs/ + diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/button_free.PNG b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/button_free.PNG new file mode 100644 index 0000000000000000000000000000000000000000..b80aceadf58550e9201369e17f09a6d07ed95970 GIT binary patch literal 2389 zcmV-b399yqP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2;EQ@#M*q?F*Lwti{6+7G|*^u3(+FKVE?_H;P+VYSE^0 zA9Ky{LAq#$8Cxg_-*63 zQB;812LfWeJ
jo@ZgHCo1;SXqrDurPr?stQn8)_}W151^VdVBQfz{0o0u58_7- z;%YMx&lLHs?3Up3G7;$YI;^a$NMV8#&q3lK=kz4RVlfH4o^r%|n658I&i*|(e4!0f zOFk^~zOWv(M-Sq3yAj^V|FFhb6ym}NDvlmO`Jf9cvcA|#RJtvNqs&h%1nWcxuAaMy z`avtg>|G_^gUr`A1kMrXDOn^W0^*q>KV28SUJ(kNPK#(XDuoF$;-r(4<>h5bApFTe zbsCd$L_By{UxZ^>$C0@|183?6U~&c!p}v3?SC23e{BD2{h$QU8E~qu9Xt{87l!L$J8H|TaA#x&o-nng2E@l^93{6Ar(6sa`7IU; zyrKsRtww_gyCzVGAOlW5fhM3n`Giythr?TgkQ4>frLRT^#bl(2|b>KV_q$eF&-m{<*n1h#n?_M~@yM#6lm12`&H{u-PPJN8c&Xb4w6( zVSk2fJsEqYev_#5)@r&$LPFw^Yy0~v`!KO2l2`y0!4na*_;r8T0MP}4RDlfZ4Z7Reh{E(D7FMx&8!9s!D}sVVsVekl(~CZF2n z@Uc53L0(QNyf%zUB51(_y&a;DeOUVlYH~Aiy0#HT`}g5wiyAh!7lO6{Sw9}ewQ1L< z@m|4((VD~9fBY5M4h~gt6;P1S}^Q(b*V5tj!;UbF>!65ADIO@4iD06Ty;;tLa;CxjR`m~PE{VBxPxJecSj|h|;>h=0WB$%9>lm=2R zKn8LF(2opq=ZPO35^cPkQV3Q&xK@Dd!X^xBt#C{2>_ht;7^%*|f!({1(>#SmhX9W# zK;M*$AHL5*d2=uB4|n0_#Z08_JB?N&jT2y>SED_D9}XU`Kx^+H`uqDZteMBmSO=>9 zlZVUqjBv5&q3LUevY-TYeX}3u{0ytA6;)>r;rm?~C~fM7*8XLGs*ubPZ{q@?Cl>;3 zb~^sGS}oje7Zei{BwuH#-fwfC$gl@4Rw13P8{5gw6r}qoL7YojR!&B$Co8IVbOFznR@`c)Ar(EP6_J! z4KS$g;z~gwYPw942(fjN8u$f~5Ip-6k9v=9^?C!f9W@mTO`aA(d<1D#l zS3{BQ@vAR4SG9 zLjtLTR6>RXK9D=)lgTF_@%%gCz~ZbCx+xU~?_9@4N(g(^ux`OS;aqSeb42B25zuC* zeQqmpz9%ns00000NkvXX Hu0mjflmbsg literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/button_pressed.PNG b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/button_pressed.PNG new file mode 100644 index 0000000000000000000000000000000000000000..afede213c0edeabc9c38fb7ce156874f28b66a82 GIT binary patch literal 3136 zcmV-G48QYPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D3)M+PK~!i%?V9;l zQ`a8F-yhg26>va6tY{bo5t)-f5&{GQ80H}%OkogE)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<$o&WZnDHCB;^=fz35o^=d4qUbbaV}wQCR(=0Y z2_I%?zVO5@AYj@MsY8|w1U)1aau#5XA;6Hte;F`CysF3~7;RgC@o^N7YI5CwB*Cl%w5-%iy0vSi7ZBuHSwsntACg_`s4S^A=)M(M!{xo_!dH8D`3PZ#B5gy zUX*8GxW660`@R5U**<~6788aWa(TWrGF0+ZLYia|5~mo1QAC#bysLkQHu)vIq=c{H z7nt-~V*9*08)LUF;*Z%c{!nL`MaTHPK0IwK#;{c{rx6!JjjJ_(S6{92FwN-k(yYf& zdleinAK{Osg;g;A{PRx;EiTMsZfYFkcYna+1|#m4Dsj6wb5~!v?w4odc}F$u0}n7K z*;oGqbCXfdS{RT0000i_@% literal 0 HcmV?d00001 diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/light_16x16.png b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/icons/light_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..8b3abbd5e9b85fdff73b372ef0cd011268de54d7 GIT binary patch literal 732 zcmV<20wev2P)7-rC1y8yiDmP;aqWRnlMV7i3*OZ zF{E_L!j&f-0ZRAkd%}_0&=qLjIyklkk%{&1{&?5F`YiO)5%$BwcNStLox!Cn8wkz3 ze_-%=*mty>RvH|chof;Yj|P9R9iEm4;nbVQIvw69=`i+RIK<0sfNjUYwvs3`*Mi66 zs)Ff%2E1%AlKv9yZRz2VTc4nFADFs`=fG?ml77PRHX;3CNxi{HNu;R?iWsw25-&Cu zObAoJ$tLLbG#StjcsUCD45%~3A?`$}azj)M62;xrd|cP`rbuIOm&7y&jCM^AvTOT6 zXRj2eQb3a^E7ulbIJvMBVMeR_oo<=BAIWd@z0xh++GFrv1uCMmM{eQx!47nHbs_q5 z5g%vfFu(Z~*UZ=N_mVYKiDSW5n!XG?jdd^$RE??z`MeE(eX~2Ix@1)i*yQA7BjuB7 z5{vmnAP~4TJ~oc2skg}Gc5r@RATu~L)DVlsM(KQ>u&mJ6*Ejb^fB^ua9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`uV#F z^`C|OIFk81Rs5Z_o~-USLjIHc{WN3zGyfmwB%TL5zY{0)ulWCuG0&gb{71#flU8A2h_^~I-{aw)0JGrOxN&hsAf5`efYa3E + + @@ -77,6 +84,9 @@ + + \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml new file mode 100644 index 0000000..937c518 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml @@ -0,0 +1,80 @@ +#%RAML 0.8 +#RAML for Light Resource +title: Resource Light +version: 1.0 +mediaType : application/json +schemas: +- lightPublish: !include oic.light.json +resourceTypes: + - typeDelete: + description: mdescription + delete: + description: mDeletedescription + +/oic/light: + displayName: Resource Light + description: | + Resource to be exposed by any OIC Device that can act as Light + type: typeDelete + get: + description: | + Get the attributes of light + responses: + 200: + description: | + Respond with the selector criteria + body: + application/json: + schema: lightPublish + example: | + { + + } + put: + description: Publish the resource information. + body: + application/json: + schema: lightPublish + responses: + 200: + description: This value is used by to update the attributes. + body: + application/json: + schema: lightPublish + example: | + { + + } + 400: + description: not found. + body: + application/json: + schema: lightPublish + example: | + { + + } + post: + description: Publish the resource information. + body: + application/json: + schema: lightPublish + responses: + 200: + description: This value is used by to update the attributes. + body: + application/json: + schema: lightPublish + example: | + { + + } + 400: + description: not found. + body: + application/json: + schema: lightPublish + example: | + { + + } \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json new file mode 100644 index 0000000..7474deb --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json @@ -0,0 +1,21 @@ +{ + "title": "light", + "rt": "oic.light", + "if": "oic.if.baseline", + "properties": { + "power": { + "type": "string", + "description": "Light status", + "values": ["on","off"], + "default": "on", + "update_frequency": 1000 + }, + "intensity": { + "type": "integer", + "description": "brightness of the light", + "range": [1,9], + "default": 1, + "update_frequency": 1001 + } + } +} \ 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 c358680..3298740 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,8 +1,12 @@ package oic.simulator.serviceprovider; +import java.net.URL; + import oic.simulator.serviceprovider.manager.LogManager; import oic.simulator.serviceprovider.manager.ResourceManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -66,4 +70,14 @@ public class Activator extends AbstractUIPlugin { private static void setLogManager(LogManager logManager) { Activator.logManager = logManager; } + + public Image getImage(String imagePath) { + Image img = null; + if (null == imagePath || imagePath.length() < 1) { + return img; + } + URL imageURL = getBundle().getEntry(imagePath); + ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL); + return descriptor.createImage(); + } } \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IObserverListChangedUIListener.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IObserverListChangedUIListener.java new file mode 100644 index 0000000..702ba11 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IObserverListChangedUIListener.java @@ -0,0 +1,5 @@ +package oic.simulator.serviceprovider.listener; + +public interface IObserverListChangedUIListener { + public void onObserverListChanged(String resourceURI); +} 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 index 7016df5..6a3b2c2 100644 --- 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 @@ -1,8 +1,12 @@ package oic.simulator.serviceprovider.listener; +import java.util.Set; + import oic.simulator.serviceprovider.resource.ModelChangeNotificationType; +import oic.simulator.serviceprovider.resource.LocalResourceAttribute; public interface IResourceModelChangedUIListener { public void onResourceModelChange( - ModelChangeNotificationType notificationType, String resourceURI); + ModelChangeNotificationType notificationType, String resourceURI, + Set changeSet); } 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 9f4c4e5..3b38019 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,36 +1,50 @@ package oic.simulator.serviceprovider.manager; +import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; 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.IObserverListChangedUIListener; import oic.simulator.serviceprovider.listener.IResourceListChangedUIListener; import oic.simulator.serviceprovider.listener.IResourceModelChangedUIListener; import oic.simulator.serviceprovider.listener.IResourceSelectionChangedUIListener; +import oic.simulator.serviceprovider.resource.LocalResourceAttribute; 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 oic.simulator.serviceprovider.utils.Utility; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; import org.oic.simulator.AutomationType; import org.oic.simulator.IAutomation; +import org.oic.simulator.ResourceAttribute; +import org.oic.simulator.ResourceAttribute.Range; +import org.oic.simulator.ResourceAttribute.Type; import org.oic.simulator.SimulatorManager; -import org.oic.simulator.SimulatorResourceAttribute; +import org.oic.simulator.SimulatorResourceModel; +import org.oic.simulator.serviceprovider.IObserver; import org.oic.simulator.serviceprovider.IResourceModelChangedListener; -import org.oic.simulator.serviceprovider.SimulatorResourceModel; +import org.oic.simulator.serviceprovider.ObserverInfo; import org.oic.simulator.serviceprovider.SimulatorResourceServer; public class ResourceManager { private Map> resourceMap; + private Map> orderedResourceUriMap; + private StandardConfiguration stdConfig; private SimulatorResource currentResourceInSelection; @@ -43,10 +57,14 @@ public class ResourceManager { private List automationUIListeners; + private List observerUIListeners; + private IResourceModelChangedListener resourceModelChangeListener; private IAutomation automationListener; + private IObserver observer; + private NotificationSynchronizerThread synchronizerThread; private Thread threadHandle; @@ -57,15 +75,14 @@ public class ResourceManager { public ResourceManager() { resourceMap = new HashMap>(); + orderedResourceUriMap = new HashMap>(); stdConfig = new StandardConfiguration(); resourceListChangedUIListeners = new ArrayList(); resourceSelectionChangedUIListeners = new ArrayList(); resourceModelChangedUIListeners = new ArrayList(); automationUIListeners = new ArrayList(); - - // Populate standard configuration file list - populateStandardConfigurationList(); + observerUIListeners = new ArrayList(); resourceModelChangeListener = new IResourceModelChangedListener() { @@ -84,26 +101,27 @@ public class ResourceManager { return; } // Fetch the resource attributes - Map resourceAttributeMapNew; + Map resourceAttributeMapNew; resourceAttributeMapNew = fetchResourceAttributesFromModel(resourceModelN); if (null == resourceAttributeMapNew) { return; } // Update the resource with new model data - Map resourceAttributeMapOld; + Map resourceAttributeMapOld; resourceAttributeMapOld = resource .getResourceAttributesMap(); if (null == resourceAttributeMapOld) { return; } ModelChangeNotificationType notificationType; + Set changeSet = new HashSet(); notificationType = compareAndUpdateLocalAttributes( resourceAttributeMapOld, - resourceAttributeMapNew); + resourceAttributeMapNew, changeSet); if (notificationType != ModelChangeNotificationType.NONE) { // Update the UI listeners resourceModelChangedUINotification( - notificationType, resourceURI); + notificationType, resourceURI, changeSet); } } }); @@ -119,24 +137,31 @@ public class ResourceManager { @Override public void run() { + System.out.println("onAutomationComplete() entry"); SimulatorResource resource = getSimulatorResourceByURI(resourceURI); if (null == resource) { return; } + System.out + .println("onAutomationComplete() resource is not null"); // Checking whether this notification is for an // attribute or a resource if (resource.isResourceAutomationInProgress()) { + System.out + .println("onAutomationComplete() for resource"); changeResourceLevelAutomationStatus(resource, false); // Notify the UI listeners automationCompleteUINotification(resourceURI, null); } else if (resource.isAttributeAutomationInProgress()) { + System.out + .println("onAutomationComplete() for attribute"); // Find the attribute with the given automation id - ResourceAttribute attribute; + LocalResourceAttribute attribute; attribute = getAttributeWithGivenAutomationId( resource, automationId); if (null != attribute) { attribute.setAutomationInProgress(false); - resource.setAttributeAutomationInProgress(false); + resource.setAttributeAutomationInProgress(isAnyAttributeInAutomation(resource)); // Notify the UI listeners automationCompleteUINotification(resourceURI, attribute.getAttributeName()); @@ -150,6 +175,44 @@ public class ResourceManager { } }; + observer = new IObserver() { + + @Override + public void onObserverChanged(final String resourceURI, + final int status, final ObserverInfo observer) { + System.out.println("onObserverListChanged in Manager"); + new Thread() { + @Override + public void run() { + if (null == resourceURI) { + return; + } + System.out.println("URI:" + resourceURI); + SimulatorResource resource = getSimulatorResourceByURI(resourceURI); + if (null == resource) { + return; + } + System.out.println("Resource Exist"); + // Update the observers information + if (status == 0) { + resource.addObserverInfo(observer); + } else { + resource.removeObserverInfo(observer); + } + + System.out.println(observer.getAddress() + "," + + observer.getPort() + "," + observer.getId()); + + System.out.println(resource.getObserver()); + + System.out.println("status:" + status); + // Notify the UI listeners + observerListChangedUINotification(resourceURI); + } + }.start(); + } + }; + synchronizerThread = new NotificationSynchronizerThread(); threadHandle = new Thread(synchronizerThread); threadHandle.setName("Simulator service provider event queue"); @@ -197,36 +260,13 @@ public class ResourceManager { } } - private void populateStandardConfigurationList() { - // TODO: Add all the standard configuration files - // Ex: stdConfig.addResourceConfiguration(LIGHT, LIGHT_FILE); + // This method gives a list of available RAML resource configurations. + public Map getResourceConfigurationList() { + return stdConfig.getStandardResourceConfigurationList(); } - // This method gives a list of RAML resource configurations available. - public List getResourceConfigurationList() { - List resourceConfigurationList = new ArrayList(); - synchronized (stdConfig) { - Map configMap = stdConfig - .getStandardResourceConfigurationList(); - if (null != configMap) { - Set keySet = configMap.keySet(); - Iterator keyItr = keySet.iterator(); - while (keyItr.hasNext()) { - resourceConfigurationList.add(keyItr.next()); - } - } - } - return resourceConfigurationList; - } - - public String getConfigFilePath(String resourceType) { - String path = null; - if (null != resourceType) { - synchronized (stdConfig) { - path = stdConfig.getResourceConfigFilePath(resourceType); - } - } - return path; + public String getConfigFilePath(String fileName) { + return stdConfig.getFilePath(fileName); } public void addResourceListChangedUIListener( @@ -258,6 +298,13 @@ public class ResourceManager { } } + public void addObserverListChangedUIListener( + IObserverListChangedUIListener observerListChangedUIListener) { + synchronized (observerUIListeners) { + observerUIListeners.add(observerListChangedUIListener); + } + } + public void removeResourceListChangedUIListener( IResourceListChangedUIListener listener) { synchronized (resourceListChangedUIListeners) { @@ -294,6 +341,15 @@ public class ResourceManager { } } + public void removeObserverListChangedUIListener( + IObserverListChangedUIListener listener) { + synchronized (observerUIListeners) { + if (null != listener && observerUIListeners.size() > 0) { + observerUIListeners.remove(listener); + } + } + } + public synchronized SimulatorResource getCurrentResourceInSelection() { return currentResourceInSelection; } @@ -303,6 +359,41 @@ public class ResourceManager { this.currentResourceInSelection = resource; } + private void addResourceUriToOrderedMap(String resourceType, + String resourceURI) { + if (null != resourceURI && null != resourceType) { + synchronized (orderedResourceUriMap) { + ArrayList uriListForType = orderedResourceUriMap + .get(resourceType); + if (null == uriListForType) { + uriListForType = new ArrayList(); + orderedResourceUriMap.put(resourceType, uriListForType); + } + uriListForType.add(resourceURI); + } + } + } + + private void removeResourceUriFromOrderedMap(String resourceType, + String resourceURI) { + synchronized (orderedResourceUriMap) { + if (null != resourceURI && null != resourceType) { + ArrayList uriListForType = orderedResourceUriMap + .get(resourceType); + if (null != uriListForType) { + uriListForType.remove(resourceURI); + if (uriListForType.size() < 1) { + orderedResourceUriMap.remove(resourceType); + } + } + } else if (null != resourceURI) { + orderedResourceUriMap.remove(resourceType); + } else { + orderedResourceUriMap.clear(); + } + } + } + private void addResourceToMap(SimulatorResource simulatorResource) { if (null != simulatorResource) { synchronized (resourceMap) { @@ -368,14 +459,23 @@ public class ResourceManager { SimulatorResourceServer resourceServerN; resourceServerN = SimulatorManager.createResource( configFilePath, resourceModelChangeListener); - + if (null == resourceServerN) { + return; + } SimulatorResource simulatorResource; simulatorResource = fetchResourceData(resourceServerN); if (null != simulatorResource) { addResourceToMap(simulatorResource); - + addResourceUriToOrderedMap( + simulatorResource.getResourceType(), + simulatorResource.getResourceURI()); resourceCreatedUINotification(); + + // Print the resource data + simulatorResource.printResourceInfo(); } + // Set the observer for the created resource + resourceServerN.setObserverCallback(observer); } }.start(); } @@ -401,7 +501,11 @@ public class ResourceManager { if (null != resource) { uri = resource.getResourceURI(); resourceTypeMap.put(uri, resource); + addResourceUriToOrderedMap(resource.getResourceType(), + uri); } + // Set the observer for the created resource + resourceServerN.setObserverCallback(observer); } // Find the resourceType and add it to the local data @@ -443,7 +547,7 @@ public class ResourceManager { simulatorResource.setResourceModel(resourceModelN); // Fetch the resource attributes - Map resourceAttributeMap; + Map resourceAttributeMap; resourceAttributeMap = fetchResourceAttributesFromModel(resourceModelN); if (null != resourceAttributeMap) { simulatorResource @@ -454,26 +558,26 @@ public class ResourceManager { return simulatorResource; } - private Map fetchResourceAttributesFromModel( + private Map fetchResourceAttributesFromModel( SimulatorResourceModel resourceModelN) { - Map resourceAttributeMap = null; + Map resourceAttributeMap = null; if (null != resourceModelN) { - Map attributeMapN; + Map attributeMapN; attributeMapN = resourceModelN.getAttributes(); if (null != attributeMapN) { - resourceAttributeMap = new HashMap(); + resourceAttributeMap = new HashMap(); Set attNameSet = attributeMapN.keySet(); String attName; Object attValueObj; - SimulatorResourceAttribute attributeN; - ResourceAttribute attribute; + ResourceAttribute attributeN; + LocalResourceAttribute attribute; Iterator attNameItr = attNameSet.iterator(); while (attNameItr.hasNext()) { attName = attNameItr.next(); attributeN = attributeMapN.get(attName); if (null != attributeN) { - attribute = new ResourceAttribute(); + attribute = new LocalResourceAttribute(); attribute.setResourceAttribute(attributeN); attribute.setAttributeName(attName); @@ -482,18 +586,29 @@ public class ResourceManager { 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 + // Set the attribute type + attribute.setAttValBaseType(attributeN.getBaseType()); + attribute.setAttValType(attributeN.getType()); + + // Set the range and allowed values + Range range = attributeN.getRange(); + if (null != range) { + attribute.setMinValue(range.getMin()); + attribute.setMaxValue(range.getMax()); + System.out.println("Fetching range"); + System.out.println(range.getMin() + "," + + range.getMax()); + } else { + Object[] values = attributeN.getAllowedValues(); + System.out.println("Size of allowed values:" + + values.length); + if (null != values && values.length > 0) { + List valueList = new ArrayList(); + for (Object obj : values) { + valueList.add(obj); + } + attribute.setAllowedValues(valueList); + } } // Initially disabling the automation @@ -653,12 +768,15 @@ public class ResourceManager { String resourceURI) { if (null != resourceType && null != resourceURI) { removeResourceFromMap(resourceType, resourceURI); + removeResourceUriFromOrderedMap(resourceType, resourceURI); } else { synchronized (resourceMap) { if (null != resourceType) { + removeResourceUriFromOrderedMap(resourceType, null); resourceMap.remove(resourceType); } else { resourceMap.clear(); + removeResourceUriFromOrderedMap(null, null); } } } @@ -713,7 +831,8 @@ public class ResourceManager { } private void resourceModelChangedUINotification( - ModelChangeNotificationType notificationType, String resourceURI) { + ModelChangeNotificationType notificationType, String resourceURI, + Set changeSet) { synchronized (resourceModelChangedUIListeners) { if (resourceModelChangedUIListeners.size() > 0 && notificationType != ModelChangeNotificationType.NONE @@ -725,7 +844,7 @@ public class ResourceManager { listener = listenerItr.next(); if (null != listener) { listener.onResourceModelChange(notificationType, - resourceURI); + resourceURI, changeSet); } } } @@ -765,6 +884,22 @@ public class ResourceManager { } } + private void observerListChangedUINotification(String resourceURI) { + synchronized (observerUIListeners) { + if (observerUIListeners.size() > 0 && null != resourceURI) { + IObserverListChangedUIListener listener; + Iterator listenerItr = observerUIListeners + .iterator(); + while (listenerItr.hasNext()) { + listener = listenerItr.next(); + if (null != listener) { + listener.onObserverListChanged(resourceURI); + } + } + } + } + } + public List getResourceTypeList() { List typeList = null; synchronized (resourceMap) { @@ -789,22 +924,29 @@ public class ResourceManager { 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()); - } + public List getURIList() { + List list = null; + synchronized (orderedResourceUriMap) { + Set typeSet = orderedResourceUriMap.keySet(); + List typeList = Utility.convertSetToList(typeSet); + if (null == typeList || typeList.size() < 1) { + return null; + } + list = new ArrayList(); + + // Sort the types + Collections.sort(typeList); + + // Add all URIs to the output list + Iterator typeItr = typeList.iterator(); + while (typeItr.hasNext()) { + List l = orderedResourceUriMap.get(typeItr.next()); + if (null != l) { + list.addAll(l); } } } - return uriList; + return list; } public void resourceSelectionChanged(final String selectedItem) { @@ -846,12 +988,14 @@ public class ResourceManager { propValue = resource.getResourceType(); } else if (propName.equals(Constants.RESOURCE_UID)) { // propValue = resource.getResourceUID(); - propValue = "Dummy123"; // Temporarily adding dummy value to - // see in UI + propValue = "Dummy123"; // TODO: Temporarily adding dummy + // value to + // show in UI } else if (propName.equals(Constants.CONNECTIVITY_TYPE)) { // propValue = resource.getConnectivityType(); - propValue = "IP"; // Temporarily adding dummy value to see - // in UI + propValue = "IP"; // TODO: Temporarily adding dummy value to + // see + // show UI } else { propValue = null; } @@ -865,16 +1009,16 @@ public class ResourceManager { return null; } - public List getAttributes(SimulatorResource resource) { - List attList = null; + public List getAttributes(SimulatorResource resource) { + List attList = null; if (null != resource) { - Map attMap = resource + Map attMap = resource .getResourceAttributesMap(); if (null != attMap && attMap.size() > 0) { - attList = new ArrayList(); + attList = new ArrayList(); Set attNameSet = attMap.keySet(); String attName; - ResourceAttribute attribute; + LocalResourceAttribute attribute; // ResourceAttribute attributeClone; Iterator attNameItr = attNameSet.iterator(); while (attNameItr.hasNext()) { @@ -896,21 +1040,50 @@ public class ResourceManager { if (null != resource && null != attributeName && null != value) { SimulatorResourceServer server = resource.getResourceServer(); if (null != server) { - server.updateAttributeStringN(attributeName, value); + LocalResourceAttribute att = resource + .getAttribute(attributeName); + if (null == att) { + return; + } + Type baseType = att.getAttValBaseType(); + if (baseType == Type.STRING) { + server.updateAttributeStringN(attributeName, value); + } else if (baseType == Type.INT) { + int val; + try { + val = Integer.parseInt(value); + } catch (NumberFormatException nfe) { + return; + } + server.updateAttributeInteger(attributeName, val); + } else if (baseType == Type.DOUBLE) { + double val; + try { + val = Double.parseDouble(value); + } catch (NumberFormatException nfe) { + return; + } + server.updateAttributeDouble(attributeName, val); + } else if (baseType == Type.BOOL) { + boolean val; + val = Boolean.parseBoolean(value); + server.updateAttributeBoolean(attributeName, val); + } } } } private ModelChangeNotificationType compareAndUpdateLocalAttributes( - Map resourceAttributeMapOld, - Map resourceAttributeMapNew) { + Map resourceAttributeMapOld, + Map resourceAttributeMapNew, + Set changeSet) { ModelChangeNotificationType notificationType = ModelChangeNotificationType.NONE; if (null != resourceAttributeMapOld && null != resourceAttributeMapNew) { Set oldMapKeySet = resourceAttributeMapOld.keySet(); Iterator attributeMapOldItr = oldMapKeySet.iterator(); String attName; - ResourceAttribute attributeOld; - ResourceAttribute attributeNew; + LocalResourceAttribute attributeOld; + LocalResourceAttribute attributeNew; Object attValueOld; Object attValueNew; String oldValueStr; @@ -935,6 +1108,7 @@ public class ResourceManager { if (!oldValueStr.equals(newValueStr)) { attributeOld.setAttributeValue(attValueNew); notificationType = ModelChangeNotificationType.ATTRIBUTE_VALUE_CHANGED; + changeSet.add(attributeOld); } } } @@ -950,7 +1124,7 @@ public class ResourceManager { if (resourceAttributeMapNew.size() > 0) { Set remainingAttSet = resourceAttributeMapNew.keySet(); Iterator remainingAttItr = remainingAttSet.iterator(); - ResourceAttribute attribute; + LocalResourceAttribute attribute; while (remainingAttItr.hasNext()) { attName = remainingAttItr.next(); if (null != attName) { @@ -967,7 +1141,7 @@ public class ResourceManager { } public int startAutomation(SimulatorResource resource, - ResourceAttribute attribute, AutomationType autoType, + LocalResourceAttribute attribute, AutomationType autoType, int autoUpdateInterval) { int autoId = -1; if (null != resource && null != attribute) { @@ -979,36 +1153,65 @@ public class ResourceManager { autoType.ordinal(), automationListener); if (-1 != autoId) { attribute.setAutomationId(autoId); + attribute.setAutomationType(autoType); + attribute.setAutomationUpdateInterval(autoUpdateInterval); + attribute.setAutomationInProgress(true); + resource.setAttributeAutomationInProgress(true); } else { attribute.setAutomationInProgress(false); - resource.setAttributeAutomationInProgress(false); } } } return autoId; } - public void stopAutomation(SimulatorResource resource, int autoId) { + public void stopAutomation(SimulatorResource resource, + LocalResourceAttribute att, int autoId) { if (null != resource) { SimulatorResourceServer resourceServerN = resource .getResourceServer(); if (null != resourceServerN) { resourceServerN.stopAutomation(autoId); + // Change the automation status + att.setAutomationInProgress(false); + resource.setAttributeAutomationInProgress(isAnyAttributeInAutomation(resource)); } } } - private ResourceAttribute getAttributeWithGivenAutomationId( + private boolean isAnyAttributeInAutomation(SimulatorResource resource) { + if (null == resource) { + return false; + } + Map attMap = resource + .getResourceAttributesMap(); + if (null == attMap) { + return false; + } + boolean status = false; + Set keySet = attMap.keySet(); + Iterator attItr = keySet.iterator(); + while (attItr.hasNext()) { + LocalResourceAttribute attribute = attMap.get(attItr.next()); + if (attribute.isAutomationInProgress()) { + status = true; + break; + } + } + return status; + } + + private LocalResourceAttribute getAttributeWithGivenAutomationId( SimulatorResource resource, int automationId) { - ResourceAttribute targetAttribute = null; + LocalResourceAttribute targetAttribute = null; if (null != resource) { - Map attributeMap = resource + Map attributeMap = resource .getResourceAttributesMap(); if (null != attributeMap) { Set attNameSet = attributeMap.keySet(); Iterator attNameItr = attNameSet.iterator(); String attName; - ResourceAttribute attribute; + LocalResourceAttribute attribute; while (attNameItr.hasNext()) { attName = attNameItr.next(); if (null != attName) { @@ -1098,13 +1301,13 @@ public class ResourceManager { private void changeResourceLevelAutomationStatus( SimulatorResource resource, boolean status) { - Map attributeMap = resource + Map attributeMap = resource .getResourceAttributesMap(); if (null != attributeMap) { Set attrNameSet = attributeMap.keySet(); Iterator attrNameItr = attrNameSet.iterator(); String attrName; - ResourceAttribute attribute; + LocalResourceAttribute attribute; while (attrNameItr.hasNext()) { attrName = attrNameItr.next(); attribute = attributeMap.get(attrName); @@ -1141,6 +1344,54 @@ public class ResourceManager { return status; } + public LocalResourceAttribute getAttributeByResourceURI(String uri, + String attName) { + if (null == uri || null == attName) { + return null; + } + SimulatorResource resource = getSimulatorResourceByURI(uri); + if (null == resource) { + return null; + } + Map attMap = resource + .getResourceAttributesMap(); + if (null == attMap) { + return null; + } + return attMap.get(attName); + } + + public void notifyObserverRequest(SimulatorResource res, int observerId) { + System.out.println("In notifyObserverRequest()"); + if (null == res) { + return; + } + SimulatorResourceServer server = res.getResourceServer(); + if (null == server) { + return; + } + server.notifyObserver(observerId); + } + + public Image getImage(String resourceURI) { + if (null == resourceURI) { + return null; + } + URL url = Activator.getDefault().getBundle() + .getEntry(getImageURL(resourceURI)); + if (null == url) { + return null; + } + return ImageDescriptor.createFromURL(url).createImage(); + } + + private String getImageURL(String resourceURI) { + // TODO: Hard-coding the image file name temporarily. + // It will be included in a separate class which manages all image + // resources + return "/icons/light_16x16.png"; + } + public void shutdown() { threadHandle.interrupt(); } 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 cb8954e..ef9033a 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 @@ -5,7 +5,9 @@ import oic.simulator.serviceprovider.view.LogView; import oic.simulator.serviceprovider.view.MetaPropertiesView; import oic.simulator.serviceprovider.view.MultiResourceOrchestrationView; import oic.simulator.serviceprovider.view.ResourceManagerView; +import oic.simulator.serviceprovider.view.ResourceObserverView; +import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; @@ -25,8 +27,13 @@ public class PerspectiveFactory implements IPerspectiveFactory { private void addViews() { factory.addView(ResourceManagerView.VIEW_ID, IPageLayout.LEFT, 0.3f, factory.getEditorArea()); - factory.addView(MetaPropertiesView.VIEW_ID, IPageLayout.BOTTOM, 0.65f, - ResourceManagerView.VIEW_ID); + + IFolderLayout folder = factory.createFolder( + "oic.simulator.serviceprovider.perspective.folder", + IPageLayout.BOTTOM, 0.65f, ResourceManagerView.VIEW_ID); + folder.addView(MetaPropertiesView.VIEW_ID); + folder.addView(ResourceObserverView.VIEW_ID); + factory.addView(AttributeView.VIEW_ID, IPageLayout.LEFT, 0.7f, factory.getEditorArea()); factory.addView(LogView.VIEW_ID, IPageLayout.BOTTOM, 0.65f, 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 deleted file mode 100644 index 5798035..0000000 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AttributeValueType.java +++ /dev/null @@ -1,6 +0,0 @@ -package oic.simulator.serviceprovider.resource; - -// 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 -} \ 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 index 0d0d9eb..3784f5f 100644 --- 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 @@ -44,7 +44,7 @@ public class AutomationSettingHelper { } public static List getAutomationSettings( - ResourceAttribute attribute) { + LocalResourceAttribute attribute) { List settingList = null; boolean invalidSetting; if (null != attribute) { @@ -53,15 +53,6 @@ public class AutomationSettingHelper { 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() 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/LocalResourceAttribute.java similarity index 59% rename from service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ResourceAttribute.java rename to service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/LocalResourceAttribute.java index 02b0fab..ffd9499 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/LocalResourceAttribute.java @@ -1,41 +1,40 @@ 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.oic.simulator.AutomationType; -import org.oic.simulator.SimulatorResourceAttribute; +import org.oic.simulator.ResourceAttribute; +import org.oic.simulator.ResourceAttribute.Type; -public class ResourceAttribute { +public class LocalResourceAttribute { // Native object reference - private SimulatorResourceAttribute resourceAttribute; + private ResourceAttribute resourceAttribute; - private String attributeName; - private Object attributeValue; - private AttributeValueType attributeType; - private List allowedValues; + private String attributeName; + private Object attributeValue; + private Type attValType; + private Type attValBaseType; + private List allowedValues; - private Object minValue; - private Object maxValue; + private Object minValue; + private Object maxValue; - private int automationId; + private int automationId; - private boolean automationInProgress; + private boolean automationInProgress; - private int automationUpdateInterval; + private int automationUpdateInterval; - private AutomationType automationType; + private AutomationType automationType; - public SimulatorResourceAttribute getResourceAttribute() { + public ResourceAttribute getResourceAttribute() { return resourceAttribute; } - public void setResourceAttribute( - SimulatorResourceAttribute resourceAttribute) { + public void setResourceAttribute(ResourceAttribute resourceAttribute) { this.resourceAttribute = resourceAttribute; } @@ -55,14 +54,6 @@ public class ResourceAttribute { this.attributeValue = attributeValue; } - public AttributeValueType getAttributeType() { - return attributeType; - } - - public void setAttributeType(AttributeValueType attributeType) { - this.attributeType = attributeType; - } - public List getAllowedValues() { return allowedValues; } @@ -130,14 +121,29 @@ public class ResourceAttribute { this.automationId = automationId; } - public static ResourceAttribute clone(ResourceAttribute attribute) { - ResourceAttribute clone = null; + public Type getAttValType() { + return attValType; + } + + public void setAttValType(Type attValType) { + this.attValType = attValType; + } + + public Type getAttValBaseType() { + return attValBaseType; + } + + public void setAttValBaseType(Type attValBaseType) { + this.attValBaseType = attValBaseType; + } + + public static LocalResourceAttribute clone(LocalResourceAttribute attribute) { + LocalResourceAttribute clone = null; if (null != attribute) { - clone = new ResourceAttribute(); + clone = new LocalResourceAttribute(); 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()); @@ -149,33 +155,48 @@ public class ResourceAttribute { 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(); + // This method gives all known possible values of the attribute in string + // format. It takes allowed values or range of values whichever is available + public List getAllValues() { + List valueList = new ArrayList(); if (null != allowedValues) { + System.out.println("In getAllValues() - AllowedValues available"); Iterator values = allowedValues.iterator(); + Object value; while (values.hasNext()) { - valueList.add(values.next()); + value = values.next(); + if (null != value) { + valueList.add(String.valueOf(value)); + } } } else if (null != minValue && null != maxValue) { - if (attributeValue.getClass() == Integer.class) { + System.out.println("In getAllValues() - Range available"); + if (attValBaseType == Type.INT) { int min = (Integer) minValue; int max = (Integer) maxValue; for (int value = min; value <= max; value++) { - valueList.add(value); + valueList.add(String.valueOf(value)); } - } else if (attributeValue.getClass() == Double.class) { + } else if (attValBaseType == Type.DOUBLE) { double min = (Double) minValue; double max = (Double) maxValue; for (double value = min; value <= max; value++) { - valueList.add(value); + valueList.add(String.valueOf(value)); } } } - if (valueList.size() < 1) { - valueList.add(attributeValue); + if (valueList.size() < 1 && null != attributeValue) { + valueList.add(String.valueOf(attributeValue)); } return valueList; } + + public void printAttributeDetails() { + System.out.println("Attribute Name:" + attributeName); + System.out.println("Attribute Value:" + attributeValue); + System.out.println("Attribute Base Type:" + attValBaseType); + System.out.println("Attribute Type:" + attValType); + System.out.println("Allowed Values:" + allowedValues); + System.out.println("Range:" + minValue + " to " + maxValue); + } } \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ObserverDetail.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ObserverDetail.java new file mode 100644 index 0000000..512ee3d --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ObserverDetail.java @@ -0,0 +1,25 @@ +package oic.simulator.serviceprovider.resource; + +import org.oic.simulator.serviceprovider.ObserverInfo; + +public class ObserverDetail { + + private ObserverInfo observerInfo; + private boolean isClicked; + + public ObserverInfo getObserverInfo() { + return observerInfo; + } + + public void setObserverInfo(ObserverInfo observerInfo) { + this.observerInfo = observerInfo; + } + + public boolean isClicked() { + return isClicked; + } + + public void setClicked(boolean isClicked) { + this.isClicked = isClicked; + } +} 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 f1f5171..84f0605 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 @@ -1,32 +1,41 @@ package oic.simulator.serviceprovider.resource; +import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import org.oic.simulator.AutomationType; -import org.oic.simulator.serviceprovider.SimulatorResourceModel; +import org.oic.simulator.SimulatorResourceModel; +import org.oic.simulator.serviceprovider.ObserverInfo; import org.oic.simulator.serviceprovider.SimulatorResourceServer; public class SimulatorResource { - private String resourceURI; - private String resourceName; - private String resourceType; - private String resourceInterface; + private String resourceURI; + private String resourceName; + private String resourceType; + private String resourceInterface; // Native Object references - private SimulatorResourceServer resourceServer; - private SimulatorResourceModel resourceModel; + private SimulatorResourceServer resourceServer; + private SimulatorResourceModel resourceModel; - private int automationId; + private int automationId; - private boolean resourceAutomationInProgress; + private boolean resourceAutomationInProgress; - private boolean attributeAutomationInProgress; + private boolean attributeAutomationInProgress; - private int automationUpdateInterval; + private int automationUpdateInterval; - private AutomationType automationType; + private AutomationType automationType; - private Map resourceAttributesMap; + private Map resourceAttributesMap; + + private Map observers; + + public SimulatorResource() { + observers = new HashMap(); + } public String getResourceURI() { return resourceURI; @@ -76,12 +85,12 @@ public class SimulatorResource { this.resourceModel = resourceModel; } - public Map getResourceAttributesMap() { + public Map getResourceAttributesMap() { return resourceAttributesMap; } public void setResourceAttributesMap( - Map resourceAttributesMap) { + Map resourceAttributesMap) { this.resourceAttributesMap = resourceAttributesMap; } @@ -126,4 +135,51 @@ public class SimulatorResource { boolean attributeAutomationInProgress) { this.attributeAutomationInProgress = attributeAutomationInProgress; } + + public Map getObserver() { + return observers; + } + + public void addObserverInfo(ObserverInfo observer) { + if (null == observer) { + return; + } + int id = observer.getId(); + if (!observers.containsKey(id)) { + ObserverDetail obsDetail = new ObserverDetail(); + obsDetail.setObserverInfo(observer); + observers.put(id, obsDetail); + } + } + + public void removeObserverInfo(ObserverInfo observer) { + if (null == observer) { + return; + } + observers.remove(observer.getId()); + } + + public void printResourceInfo() { + System.out.println("Resource URI: " + resourceURI); + System.out.println("Resource Name: " + resourceName); + System.out.println("Resource type: " + resourceType); + System.out.println("Resource Interface: " + resourceInterface); + System.out.println("Resource Attributes:-"); + if (null != resourceAttributesMap) { + Iterator attItr = resourceAttributesMap.keySet().iterator(); + while (attItr.hasNext()) { + resourceAttributesMap.get(attItr.next()) + .printAttributeDetails();; + } + } + } + + public LocalResourceAttribute getAttribute(String attributeName) { + if (null == attributeName || null == resourceAttributesMap + || resourceAttributesMap.size() < 1) { + return null; + } + return resourceAttributesMap.get(attributeName); + } + } \ 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 2695713..1b965ed 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 @@ -1,57 +1,84 @@ package oic.simulator.serviceprovider.resource; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; -public class StandardConfiguration { +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.utils.Constants; + +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; - private String configuration_directory_path; +public class StandardConfiguration { - // A map of resourceType of standard resources as the key and the complete - // location of the file as the value - Map standardResourceConfigurationMap; + // A map of filename of standard resources as the key and the complete + // location of the file(including the filename) as the value + Map stdConfigFiles; public StandardConfiguration() { - standardResourceConfigurationMap = new HashMap(); + stdConfigFiles = new HashMap(); + addFiles(); + populateStandardConfigurationList(); } - public String getConfiguration_directory_path() { - return configuration_directory_path; + private void addFiles() { + stdConfigFiles.put(Constants.RAML_FILE_PREFIX + "light.raml", null); } - public void setConfiguration_directory_path( - String configuration_directory_path) { - this.configuration_directory_path = configuration_directory_path; + private void populateStandardConfigurationList() { + if (stdConfigFiles.isEmpty()) { + return; + } + Iterator fileItr = stdConfigFiles.keySet().iterator(); + String fileName; + URL url; + File file; + String filePath; + Bundle bundle = Activator.getDefault().getBundle(); + while (fileItr.hasNext()) { + fileName = fileItr.next(); + url = bundle.getEntry(Constants.CONFIG_DIRECTORY_PATH + "/" + + fileName); + if (null == url) { + return; + } + System.out.println("URL: " + url.toExternalForm()); + try { + file = new File(FileLocator.resolve(url).toURI()); + } catch (URISyntaxException | IOException e) { + System.out.println(e.getMessage()); + return; + } + filePath = file.getAbsolutePath(); + System.out.println(filePath); + stdConfigFiles.put(fileName, filePath); + } + + // Print for debugging purpose + Iterator itr = stdConfigFiles.keySet().iterator(); + String key; + while (itr.hasNext()) { + key = itr.next(); + System.out.println("FileName: " + key); + System.out.println("FilePath:" + stdConfigFiles.get(key)); + } } public Map getStandardResourceConfigurationList() { - return standardResourceConfigurationMap; + return stdConfigFiles; } public void setStandardResourceConfigurationList( - Map standardResourceConfigurationList) { - this.standardResourceConfigurationMap = standardResourceConfigurationList; + Map stdConfigFiles) { + this.stdConfigFiles = stdConfigFiles; } - public void addResourceConfiguration(String resourceType, - String absolutePath) { - if (null != resourceType && resourceType.length() > 0 - && null != absolutePath && absolutePath.length() > 0) { - standardResourceConfigurationMap.put(resourceType, absolutePath); - } - } - - public String getResourceConfigFilePath(String resourceType) { - String path = null; - if (null != resourceType && resourceType.length() > 0) { - path = standardResourceConfigurationMap.get(resourceType); - } - return path; - } - - public void removeResourceFromConfiguration(String resourceType) { - if (null != resourceType && resourceType.length() > 0) { - standardResourceConfigurationMap.remove(resourceType); - } + public String getFilePath(String fileName) { + return stdConfigFiles.get(fileName); } } \ 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 14d0b5a..b63a567 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 @@ -3,6 +3,9 @@ package oic.simulator.serviceprovider.utils; import org.oic.simulator.AutomationType; public class Constants { + + public static final String CONFIG_DIRECTORY_PATH = "/resource"; + public static final String UNDERSCORE = "_"; public static final String FORWARD_SLASH = "/"; @@ -29,7 +32,7 @@ public class Constants { public static final String UPDATE_INTERVAL_IN_MS = "Update Interval(ms)"; public static final String[] AUTOMATION_SETTINGS = { - AUTOMATION, AUTOMATION_TYPE, UPDATE_INTERVAL_IN_MS }; + AUTOMATION_TYPE, UPDATE_INTERVAL_IN_MS }; public static final int AUTOMATION_SETTINGS_COUNT = AUTOMATION_SETTINGS.length; @@ -45,8 +48,7 @@ public class Constants { 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[] BROWSE_RAML_FILTER_EXTENSIONS = new String[] { "*.raml" }; public static final String[] SAVE_LOG_FILTER_EXTENSIONS = new String[] { "*.log", "*" }; @@ -69,4 +71,10 @@ public class Constants { public static final String DELETE_PAGE_TITLE = "Delete Resource"; public static final String DELETE_PAGE_MESSAGE = "Select the resource(s) to be deleted"; + + public static final String RAML_FILE_PREFIX = ""; + + public static final String RAML_FILE_EXTENSION = ".raml"; + + public static final String SPLIT_BY_DOT_PATTERN = "\\."; } \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java index 481028a..160da63 100644 --- a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java @@ -1,5 +1,10 @@ package oic.simulator.serviceprovider.utils; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + public class Utility { public static String uriToDisplayName(String uri) { @@ -29,6 +34,42 @@ public class Utility { return result; } + public static String fileNameToDisplay(String fileName) { + if (null == fileName || fileName.length() < 1) { + return null; + } + // Remove the RAML file standard prefix + int len = Constants.RAML_FILE_PREFIX.length(); + if (len > 0) { + if (fileName.startsWith(Constants.RAML_FILE_PREFIX)) { + fileName = fileName.substring(len); + } + } + + // Removing the file extension + String[] token = fileName.split(Constants.SPLIT_BY_DOT_PATTERN); + int tokLen = token.length; + String result = null; + if (tokLen - 2 >= 0) { + result = token[tokLen - 2]; + } + return result; + } + + public static String displayToFileName(String displayName) { + if (null == displayName || displayName.length() < 1) { + return null; + } + String fileName; + // Adding the prefix + fileName = Constants.RAML_FILE_PREFIX + displayName; + + // Adding the file extension + fileName = fileName + Constants.RAML_FILE_EXTENSION; + + return fileName; + } + public static boolean isUriComplete(String uri) { boolean uriComplete = false; if (null != uri) { @@ -76,4 +117,16 @@ public class Utility { } return result; } + + public static List convertSetToList(Set typeSet) { + if (null == typeSet) { + return null; + } + List list = new ArrayList(); + Iterator typeItr = typeSet.iterator(); + while (typeItr.hasNext()) { + list.add(typeItr.next()); + } + return list; + } } \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeEditingSupport.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeEditingSupport.java new file mode 100644 index 0000000..3d9a78b --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeEditingSupport.java @@ -0,0 +1,239 @@ +package oic.simulator.serviceprovider.view; + +import java.util.List; + +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.manager.ResourceManager; +import oic.simulator.serviceprovider.resource.AutomationSettingHelper; +import oic.simulator.serviceprovider.resource.LocalResourceAttribute; +import oic.simulator.serviceprovider.resource.SimulatorResource; +import oic.simulator.serviceprovider.utils.Utility; +import oic.simulator.serviceprovider.view.dialogs.AutomationSettingDialog; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.eclipse.jface.viewers.ComboBoxCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.MessageBox; +import org.oic.simulator.AutomationType; + +public class AttributeEditingSupport { + + private AttributeValueEditor attValueEditor; + private AutomationEditor automationEditor; + + public AttributeValueEditor createAttributeValueEditor(TableViewer viewer) { + attValueEditor = new AttributeValueEditor(viewer); + return attValueEditor; + } + + public AutomationEditor createAutomationEditor(TableViewer viewer) { + automationEditor = new AutomationEditor(viewer); + return automationEditor; + } + + class AttributeValueEditor extends EditingSupport { + + private final TableViewer viewer; + private LocalResourceAttribute attributeInSelection; + private CCombo comboBox; + + public AttributeValueEditor(TableViewer viewer) { + super(viewer); + this.viewer = viewer; + } + + @Override + protected boolean canEdit(Object arg0) { + return true; + } + + @Override + protected CellEditor getCellEditor(Object element) { + attributeInSelection = (LocalResourceAttribute) element; + + // CellEditor is not required as the automation is in progress. + if (attributeInSelection.isAutomationInProgress()) { + return null; + } + + String values[] = null; + List valueSet = attributeInSelection.getAllValues(); + System.out.println("Values obtained in getCellEditor: " + valueSet); + values = convertListToString(valueSet); + + ComboBoxCellEditor comboEditor = new ComboBoxCellEditor( + viewer.getTable(), values, SWT.READ_ONLY); + comboBox = (CCombo) comboEditor.getControl(); + comboBox.addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent event) { + String oldValue = String.valueOf(attributeInSelection + .getAttributeValue()); + String newValue = comboBox.getText(); + if (!oldValue.equals(newValue)) { + attributeInSelection.setAttributeValue(newValue); + MessageBox dialog = new MessageBox(viewer.getTable() + .getShell(), SWT.ICON_QUESTION | SWT.OK + | SWT.CANCEL); + dialog.setText("Confirm action"); + dialog.setMessage("Do you want to modify the value?"); + int retval = dialog.open(); + if (retval != SWT.OK) { + attributeInSelection.setAttributeValue(oldValue); + } else { + ResourceManager resourceManager; + resourceManager = Activator.getDefault() + .getResourceManager(); + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + resourceManager.attributeValueUpdated(resource, + attributeInSelection.getAttributeName(), + newValue); + } + viewer.update(attributeInSelection, null); + comboBox.setVisible(false); + } + } + }); + return comboEditor; + } + + @Override + protected Object getValue(Object element) { + int indexOfItem = 0; + LocalResourceAttribute att = (LocalResourceAttribute) element; + String valueString = String.valueOf(att.getAttributeValue()); + List valueSet = att.getAllValues(); + if (null != valueSet) { + indexOfItem = valueSet.indexOf(valueString); + } + if (indexOfItem == -1) { + indexOfItem = 0; + } + return indexOfItem; + } + + @Override + protected void setValue(Object element, Object value) { + Object valueObj = attributeInSelection.getAttributeValue(); + if (null == valueObj) + return; + String attValue = String.valueOf(valueObj); + ((LocalResourceAttribute) element).setAttributeValue(attValue); + viewer.update(element, null); + } + + public String[] convertListToString(List valueList) { + String[] strArr; + if (null != valueList && valueList.size() > 0) { + strArr = valueList.toArray(new String[1]); + } else { + strArr = new String[1]; + } + return strArr; + } + } + + class AutomationEditor extends EditingSupport { + + private final TableViewer viewer; + + public AutomationEditor(TableViewer viewer) { + super(viewer); + this.viewer = viewer; + } + + @Override + protected boolean canEdit(Object arg0) { + return true; + } + + @Override + protected CellEditor getCellEditor(Object element) { + // CellEditor is not required as the automation is in progress. + ResourceManager resourceManager = Activator.getDefault() + .getResourceManager(); + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null != resource && resource.isResourceAutomationInProgress()) { + return null; + } + return new CheckboxCellEditor(null, SWT.CHECK | SWT.READ_ONLY); + } + + @Override + protected Object getValue(Object element) { + System.out.println("In getValue() automation"); + LocalResourceAttribute att = (LocalResourceAttribute) element; + return att.isAutomationInProgress(); + } + + @Override + protected void setValue(Object element, Object value) { + System.out.println("In setValue() automation"); + + ResourceManager resourceManager = Activator.getDefault() + .getResourceManager(); + // As automation depends on the current resource in selection, its + // presence is being checked. + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null == resource) { + return; + } + + LocalResourceAttribute att = (LocalResourceAttribute) element; + boolean checked = (Boolean) value; + System.out.println("Value:" + checked); + if (checked) { + // Start the automation + + // Fetch the settings data + List automationSettings; + automationSettings = AutomationSettingHelper + .getAutomationSettings(att); + + // Open the settings dialog + AutomationSettingDialog dialog = new AutomationSettingDialog( + viewer.getTable().getShell(), automationSettings); + dialog.create(); + if (dialog.open() == Window.OK) { + String automationType = dialog.getAutomationType(); + String updateFreq = dialog.getUpdateFrequency(); + + AutomationType autoType = AutomationType + .valueOf(automationType); + int updFreq = Utility + .getUpdateIntervalFromString(updateFreq); + int autoId = resourceManager.startAutomation(resource, att, + autoType, updFreq); + if (autoId == -1) { + MessageDialog.openInformation(Display.getDefault() + .getActiveShell(), "Automation Status", + "Automation start failed!!"); + } else { + viewer.update(element, null); + } + } + } else { + // Stop the automation + resourceManager.stopAutomation(resource, att, + att.getAutomationId()); + MessageDialog.openInformation(Display.getDefault() + .getActiveShell(), "Automation Status", + "Automation stopped."); + viewer.update(element, null); + } + } + } +} 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 ec47066..82956c8 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,9 +1,6 @@ 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; @@ -11,77 +8,57 @@ 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.LocalResourceAttribute; 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.graphics.Image; 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 AttributeEditingSupport attributeEditor; private IResourceSelectionChangedUIListener resourceSelectionChangedListener; private IResourceModelChangedUIListener resourceModelChangedUIListener; private IAutomationUIListener automationUIListener; - private Label newValueLbl; - private CCombo valueCmb; - private Button submitButton; - private Button clearButton; + private final String[] attTblHeaders = { "Name", + "Value", "Automation" }; + private final Integer[] attTblColWidth = { 150, 190, + 150 }; - private ResourceAttribute attributeInSelection; - private AttributeAutomationSettingEditor automationSettingEditor; - private List localSettingList; + private ResourceManager resourceManager; - 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 static final Image CHECKED = Activator + .getDefault() + .getImage( + "icons/checked.gif"); - private ResourceManager resourceManager; + private static final Image UNCHECKED = Activator + .getDefault() + .getImage( + "icons/unchecked.gif"); public AttributeView() { @@ -97,6 +74,18 @@ public class AttributeView extends ViewPart { public void run() { if (null != attTblViewer) { updateViewer(checkSelection()); + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + Table tbl = attTblViewer.getTable(); + if (!tbl.isDisposed()) { + if (null != resource + && resource + .isResourceAutomationInProgress()) { + tbl.setEnabled(false); + } else { + tbl.setEnabled(true); + } + } } } }); @@ -108,7 +97,8 @@ public class AttributeView extends ViewPart { @Override public void onResourceModelChange( final ModelChangeNotificationType notificationType, - final String resourceURI) { + final String resourceURI, + final Set changeSet) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { @@ -125,37 +115,13 @@ public class AttributeView extends ViewPart { // 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)); - } - } + if (notificationType == ModelChangeNotificationType.ATTRIBUTE_ADDED + || notificationType == ModelChangeNotificationType.ATTRIBUTE_REMOVED) { + attTblViewer.refresh(); + } else if (notificationType == ModelChangeNotificationType.ATTRIBUTE_VALUE_CHANGED) { + if (null != changeSet) { + attTblViewer.update(changeSet.toArray(), + null); } } } @@ -189,24 +155,12 @@ public class AttributeView extends ViewPart { 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(); - } + // Disabling the table to prevent interactions + // during the automation + tbl.setEnabled(false); + tbl.deselectAll(); } - - // Disable the manual change UI controls - setVisibilityForManualValueChange(false); } } }); @@ -221,6 +175,8 @@ public class AttributeView extends ViewPart { @Override public void run() { + System.out.println("onAutomationcomplete Impl: uri:" + + resourceURI + ",attname:" + attName); if (null == resourceURI) { return; } @@ -233,29 +189,29 @@ public class AttributeView extends ViewPart { 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); + if (null == uri || !uri.equals(resourceURI)) { + return; + } + Table tbl; + tbl = attTblViewer.getTable(); + if (!tbl.isDisposed()) { + if (null != attName) { + // Attribute level automation has stopped + LocalResourceAttribute att = resourceManager + .getAttributeByResourceURI(resourceURI, + attName); + System.out.println(att == null); + if (null == att) { + return; + } else { + attTblViewer.update(att, null); } + } else { + // Resource level automation has stopped + // Enabling the table which was disabled at the + // beginning of automation + tbl.setEnabled(true); + attTblViewer.refresh(); } } } @@ -268,20 +224,18 @@ public class AttributeView extends ViewPart { public void createPartControl(Composite parent) { Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE); - parent.setLayout(new GridLayout(2, false)); + parent.setLayout(new GridLayout()); 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)); + attGroup.setLayout(new GridLayout()); 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 + attTblViewer = new TableViewer(attGroup, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); createAttributeColumns(attTblViewer); @@ -294,95 +248,32 @@ public class AttributeView extends ViewPart { 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(); + List propertyList = checkSelection(); if (null != propertyList) { updateViewer(propertyList); } - - setSettingSubmitVisibility(false); } public void createAttributeColumns(TableViewer tableViewer) { + + attributeEditor = new AttributeEditingSupport(); + TableViewerColumn attName = new TableViewerColumn(tableViewer, SWT.NONE); attName.getColumn().setWidth(attTblColWidth[0]); attName.getColumn().setText(attTblHeaders[0]); - attName.setLabelProvider(new ColumnLabelProvider() { + attName.setLabelProvider(new StyledCellLabelProvider() { @Override - public String getText(Object element) { - if (element instanceof ResourceAttribute) { - ResourceAttribute attribute = (ResourceAttribute) element; + public void update(ViewerCell cell) { + Object element = cell.getElement(); + if (element instanceof LocalResourceAttribute) { + LocalResourceAttribute attribute = (LocalResourceAttribute) element; if (null != attribute) { - return attribute.getAttributeName(); + cell.setText(attribute.getAttributeName()); } } - return ""; } }); @@ -393,8 +284,8 @@ public class AttributeView extends ViewPart { attValue.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { - if (element instanceof ResourceAttribute) { - ResourceAttribute attribute = (ResourceAttribute) element; + if (element instanceof LocalResourceAttribute) { + LocalResourceAttribute attribute = (LocalResourceAttribute) element; if (null != attribute) { Object val = attribute.getAttributeValue(); if (null != val) { @@ -405,316 +296,35 @@ public class AttributeView extends ViewPart { return ""; } }); + attValue.setEditingSupport(attributeEditor + .createAttributeValueEditor(attTblViewer)); - TableViewerColumn automationStatus = new TableViewerColumn(tableViewer, + TableViewerColumn automation = new TableViewerColumn(tableViewer, SWT.NONE); - automationStatus.getColumn().setWidth(attTblColWidth[2]); - automationStatus.getColumn().setText(attTblHeaders[2]); - automationStatus.setLabelProvider(new ColumnLabelProvider() { + automation.getColumn().setWidth(attTblColWidth[2]); + automation.getColumn().setText(attTblHeaders[2]); + automation.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); - } - } + LocalResourceAttribute att = (LocalResourceAttribute) element; + if (att.isAutomationInProgress()) { + return Constants.ENABLED; } - - attTblViewer.refresh(); - - setSettingSubmitVisibility(false); + return Constants.DISABLED; } - }); - 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()); - } + public Image getImage(Object element) { + LocalResourceAttribute att = (LocalResourceAttribute) element; + if (att.isAutomationInProgress()) { + return CHECKED; + } else { + return UNCHECKED; } - setSettingSubmitVisibility(false); } }); + automation.setEditingSupport(attributeEditor + .createAutomationEditor(attTblViewer)); } private void addManagerListeners() { @@ -725,18 +335,11 @@ public class AttributeView extends ViewPart { resourceManager.addAutomationUIListener(automationUIListener); } - private void setSettingSubmitVisibility(boolean visible) { - if (!submitButton.isDisposed()) - submitButton.setEnabled(visible); - if (!clearButton.isDisposed()) - clearButton.setEnabled(visible); - } - - private List checkSelection() { + private List checkSelection() { SimulatorResource resourceInSelection = resourceManager .getCurrentResourceInSelection(); if (null != resourceInSelection) { - List attList = resourceManager + List attList = resourceManager .getAttributes(resourceInSelection); return attList; } else { @@ -744,7 +347,7 @@ public class AttributeView extends ViewPart { } } - private void updateViewer(List attList) { + private void updateViewer(List attList) { Table tbl; if (null != attList) { tbl = attTblViewer.getTable(); @@ -763,26 +366,6 @@ public class AttributeView extends ViewPart { } } } - - 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 { @@ -802,205 +385,6 @@ public class AttributeView extends ViewPart { } - 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 dispose() { // Unregister the selection listener 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 99af2ee..deb8005 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 @@ -16,6 +16,7 @@ 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 oic.simulator.serviceprovider.view.dialogs.LogDetailsDialog; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; 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 index 936d17d..4944b31 100644 --- 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 @@ -61,7 +61,7 @@ public class MetaPropertiesView extends ViewPart { public void createPartControl(Composite parent) { parent.setLayout(new GridLayout(1, false)); - tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL + tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); createColumns(tableViewer); 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 b620623..28cde2b 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 @@ -25,6 +25,7 @@ import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -67,7 +68,6 @@ public class ResourceManagerView extends ViewPart { public void run() { if (null != treeViewer) { treeViewer.refresh(); - treeViewer.expandAll(); } // Trigger the visibility of delete button @@ -84,7 +84,6 @@ public class ResourceManagerView extends ViewPart { public void run() { if (null != treeViewer) { treeViewer.refresh(); - treeViewer.expandAll(); } // Trigger the visibility of delete button @@ -192,6 +191,8 @@ public class ResourceManagerView extends ViewPart { String configFilePath; int count; configFilePath = createWizard.getConfigFilePath(); + System.out.println("Resultant config file path is " + + configFilePath); count = createWizard.getResourceCount(); if (count <= 1) { @@ -255,10 +256,8 @@ public class ResourceManagerView extends ViewPart { TreeItem selectedItem = (TreeItem) e.item; if (null != selectedItem) { String selectedItemText = selectedItem.getText(); - if (!isSelectedTreeItemACategory(selectedItemText)) { - selectedItemText = Utility - .displayNameToUri(selectedItemText); - } + selectedItemText = Utility + .displayNameToUri(selectedItemText); // Propagate this selection change event to manager resourceManager .resourceSelectionChanged(selectedItemText); @@ -279,9 +278,6 @@ public class ResourceManagerView extends ViewPart { } 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() { @@ -341,14 +337,6 @@ public class ResourceManagerView extends ViewPart { } } - private boolean isSelectedTreeItemACategory(String selectedItem) { - boolean category = false; - if (null != selectedItem) { - category = resourceManager.isTypeExist(selectedItem); - } - return category; - } - public void addManagerListeners() { resourceManager .addResourceListChangedUIListener(resourceListChangedListener); @@ -382,25 +370,17 @@ class TreeContentProvider implements ITreeContentProvider { @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(); + return null; } @Override public Object[] getElements(Object parent) { - List deptTypes; - deptTypes = Activator.getDefault().getResourceManager() - .getResourceTypeList(); - if (null == deptTypes) { - deptTypes = new ArrayList(); + List uriList; + uriList = Activator.getDefault().getResourceManager().getURIList(); + if (null == uriList) { + uriList = new ArrayList(); } - return deptTypes.toArray(); + return uriList.toArray(); } @Override @@ -410,10 +390,6 @@ class TreeContentProvider implements ITreeContentProvider { @Override public boolean hasChildren(Object parent) { - String resType = (String) parent; - if (Activator.getDefault().getResourceManager().isTypeExist(resType)) { - return true; - } return false; } } @@ -422,9 +398,14 @@ class TreeLabelProvider extends LabelProvider { @Override public String getText(Object element) { String value = (String) element; - if (!Activator.getDefault().getResourceManager().isTypeExist(value)) { - value = Utility.uriToDisplayName(value); - } + value = Utility.uriToDisplayName(value); return value; } + + @Override + public Image getImage(Object element) { + ResourceManager resourceManager = Activator.getDefault() + .getResourceManager(); + return resourceManager.getImage((String) element); + } } \ No newline at end of file diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceObserverView.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceObserverView.java new file mode 100644 index 0000000..90ecf90 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceObserverView.java @@ -0,0 +1,323 @@ +package oic.simulator.serviceprovider.view; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import oic.simulator.serviceprovider.Activator; +import oic.simulator.serviceprovider.listener.IObserverListChangedUIListener; +import oic.simulator.serviceprovider.listener.IResourceSelectionChangedUIListener; +import oic.simulator.serviceprovider.manager.ResourceManager; +import oic.simulator.serviceprovider.resource.ObserverDetail; +import oic.simulator.serviceprovider.resource.SimulatorResource; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredContentProvider; +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.graphics.Image; +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 ResourceObserverView extends ViewPart { + public static final String VIEW_ID = "oic.simulator.serviceprovider.view.observer"; + + private TableViewer tblViewer; + + private final String[] columnHeaders = { + "Client Address", "Port", "Notify" }; + + private final Integer[] columnWidth = { + 150, 75, 50 }; + + private IResourceSelectionChangedUIListener resourceSelectionChangedListener; + + private IObserverListChangedUIListener resourceObserverListChangedListener; + + private ResourceManager resourceManager; + + private static final Image NOTIFY_BUTTON_UNSELECTED = Activator + .getDefault() + .getImage( + "icons/button_free.PNG"); + + private static final Image NOTIFY_BUTTON_SELECTED = Activator + .getDefault() + .getImage( + "icons/button_pressed.PNG"); + + public ResourceObserverView() { + + resourceManager = Activator.getDefault().getResourceManager(); + + resourceSelectionChangedListener = new IResourceSelectionChangedUIListener() { + + @Override + public void onResourceSelectionChange() { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + if (null != tblViewer) { + changeButtonStatus(); + updateViewer(getData(resourceManager + .getCurrentResourceInSelection())); + } + } + }); + } + }; + + resourceObserverListChangedListener = new IObserverListChangedUIListener() { + + @Override + public void onObserverListChanged(final String resourceURI) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + System.out.println("UI callback - observer"); + if (null == resourceURI) { + return; + } + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null == resource) { + return; + } + System.out + .println("UI callback - observer - this resource"); + if (resource.getResourceURI().equals(resourceURI)) { + if (null != tblViewer) { + updateViewer(getData(resource)); + } + } + } + }); + + } + }; + } + + private Map getData(SimulatorResource resource) { + if (null == resource) { + return null; + } + return resource.getObserver(); + } + + private void updateViewer(Map observer) { + System.out.println(observer); + if (null != tblViewer) { + Table tbl = tblViewer.getTable(); + if (null != observer && observer.size() > 0) { + tblViewer.setInput(observer.entrySet().toArray()); + if (!tbl.isDisposed()) { + tbl.setLinesVisible(true); + } + } else { + if (!tbl.isDisposed()) { + tbl.removeAll(); + tbl.setLinesVisible(false); + } + } + } + } + + @Override + public void createPartControl(Composite parent) { + parent.setLayout(new GridLayout(1, false)); + + tblViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); + + createColumns(tblViewer); + + // make lines and header visible + final Table table = tblViewer.getTable(); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + tblViewer.setContentProvider(new ObserverContentProvider()); + + addManagerListeners(); + + } + + public void createColumns(TableViewer tableViewer) { + TableViewerColumn addressColumn = new TableViewerColumn(tableViewer, + SWT.NONE); + addressColumn.getColumn().setWidth(columnWidth[0]); + addressColumn.getColumn().setText(columnHeaders[0]); + addressColumn.setLabelProvider(new StyledCellLabelProvider() { + @Override + public void update(ViewerCell cell) { + Object element = cell.getElement(); + if (element instanceof Map.Entry) { + @SuppressWarnings("unchecked") + Map.Entry observer = (Map.Entry) element; + cell.setText(observer.getValue().getObserverInfo() + .getAddress()); + } + } + }); + + TableViewerColumn portColumn = new TableViewerColumn(tableViewer, + SWT.NONE); + portColumn.getColumn().setWidth(columnWidth[1]); + portColumn.getColumn().setText(columnHeaders[1]); + portColumn.setLabelProvider(new StyledCellLabelProvider() { + @Override + public void update(ViewerCell cell) { + Object element = cell.getElement(); + if (element instanceof Map.Entry) { + @SuppressWarnings("unchecked") + Map.Entry observer = (Map.Entry) element; + cell.setText(String.valueOf(observer.getValue() + .getObserverInfo().getPort())); + } + } + }); + + TableViewerColumn notifyColumn = new TableViewerColumn(tableViewer, + SWT.NONE); + notifyColumn.getColumn().setWidth(columnWidth[2]); + notifyColumn.getColumn().setText(columnHeaders[2]); + notifyColumn.setLabelProvider(new ColumnLabelProvider() { + + @Override + public String getText(Object element) { + return ""; + } + + @Override + public Image getImage(Object element) { + @SuppressWarnings("unchecked") + Map.Entry observer = (Map.Entry) element; + if (observer.getValue().isClicked()) { + return NOTIFY_BUTTON_SELECTED; + } + return NOTIFY_BUTTON_UNSELECTED; + } + }); + notifyColumn.setEditingSupport(new NotifyEditor(tableViewer)); + } + + private void addManagerListeners() { + resourceManager + .addResourceSelectionChangedUIListener(resourceSelectionChangedListener); + resourceManager + .addObserverListChangedUIListener(resourceObserverListChangedListener); + } + + class ObserverContentProvider 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 NotifyEditor extends EditingSupport { + + private final TableViewer viewer; + + public NotifyEditor(TableViewer viewer) { + super(viewer); + this.viewer = viewer; + } + + @Override + protected boolean canEdit(Object arg0) { + return true; + } + + @Override + protected CellEditor getCellEditor(Object element) { + return new CheckboxCellEditor(null, SWT.CHECK | SWT.READ_ONLY); + } + + @Override + protected Object getValue(Object element) { + System.out.println("getValue()"); + @SuppressWarnings("unchecked") + Map.Entry observer = (Map.Entry) element; + return observer.getValue().isClicked(); + } + + @Override + protected void setValue(Object element, Object value) { + System.out.println("setValue()"); + // Change the button status of all the resources + changeButtonStatus(); + + @SuppressWarnings("unchecked") + Map.Entry observer = (Map.Entry) element; + observer.getValue().setClicked(true); + viewer.refresh(); + + // Call Native Method + resourceManager.notifyObserverRequest( + resourceManager.getCurrentResourceInSelection(), observer + .getValue().getObserverInfo().getId()); + } + } + + private void changeButtonStatus() { + SimulatorResource resource = resourceManager + .getCurrentResourceInSelection(); + if (null == resource) { + return; + } + Map observerMap = resource.getObserver(); + if (null == observerMap) { + return; + } + Set keySet = observerMap.keySet(); + Iterator itr = keySet.iterator(); + while (itr.hasNext()) { + observerMap.get(itr.next()).setClicked(false); + } + } + + @Override + public void dispose() { + // Unregister the listener + if (null != resourceSelectionChangedListener) { + resourceManager + .removeResourceSelectionChangedUIListener(resourceSelectionChangedListener); + } + + if (null != resourceObserverListChangedListener) { + resourceManager + .removeObserverListChangedUIListener(resourceObserverListChangedListener); + } + super.dispose(); + } + + @Override + public void setFocus() { + } + +} diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/AutomationSettingDialog.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/AutomationSettingDialog.java new file mode 100644 index 0000000..996cdc1 --- /dev/null +++ b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/AutomationSettingDialog.java @@ -0,0 +1,151 @@ +package oic.simulator.serviceprovider.view.dialogs; + +import java.util.Iterator; +import java.util.List; + +import oic.simulator.serviceprovider.resource.AutomationSettingHelper; +import oic.simulator.serviceprovider.utils.Constants; + +import org.eclipse.jface.dialogs.TitleAreaDialog; +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.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +public class AutomationSettingDialog extends TitleAreaDialog { + + private CCombo autoTypeCmb; + private CCombo updateFreqCmb; + + private String automationType; + private String updateFrequencyInMillis; + private List automationSettings; + + public AutomationSettingDialog(Shell parentShell, + List automationSettings) { + super(parentShell); + this.automationSettings = automationSettings; + } + + @Override + public void create() { + super.create(); + setTitle("Automation Settings"); + setMessage("Fill the automation settings for the attribute"); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite compLayout = (Composite) super.createDialogArea(parent); + Composite container = new Composite(compLayout, SWT.NONE); + container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + GridLayout layout = new GridLayout(2, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + container.setLayout(layout); + + GridData gd; + + Label autoTypeLbl = new Label(container, SWT.NONE); + autoTypeLbl.setText("Automation Type"); + + autoTypeCmb = new CCombo(container, SWT.READ_ONLY | SWT.BORDER); + gd = new GridData(); + gd.horizontalAlignment = SWT.FILL; + gd.grabExcessHorizontalSpace = true; + autoTypeCmb.setLayoutData(gd); + + Label updateFreqLbl = new Label(container, SWT.NONE); + updateFreqLbl.setText("Update Frequency(ms)"); + + updateFreqCmb = new CCombo(container, SWT.READ_ONLY | SWT.BORDER); + gd = new GridData(); + gd.horizontalAlignment = SWT.FILL; + gd.grabExcessHorizontalSpace = true; + updateFreqCmb.setLayoutData(gd); + + populateSettingsData(); + + addUIListeners(); + + setInitialSettings(); + + return compLayout; + } + + public void populateSettingsData() { + Iterator settingItr = automationSettings + .iterator(); + AutomationSettingHelper setting; + String settingId; + String value; + List allowedValues; + Iterator itr; + while (settingItr.hasNext()) { + setting = settingItr.next(); + settingId = setting.getSettingID(); + value = setting.getSettingValue(); + allowedValues = setting.getAllowedValues(); + if (settingId.equals(Constants.AUTOMATION_TYPE)) { + itr = allowedValues.iterator(); + while (itr.hasNext()) { + autoTypeCmb.add(itr.next()); + } + // Select the default value + autoTypeCmb.select(autoTypeCmb.indexOf(value)); + } else if (settingId.equals(Constants.UPDATE_INTERVAL_IN_MS)) { + itr = allowedValues.iterator(); + while (itr.hasNext()) { + updateFreqCmb.add(itr.next()); + } + // Select the default value + updateFreqCmb.select(updateFreqCmb.indexOf(value)); + } + } + } + + public void addUIListeners() { + autoTypeCmb.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + automationType = autoTypeCmb.getText(); + } + }); + + updateFreqCmb.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateFrequencyInMillis = updateFreqCmb.getText(); + } + }); + } + + public void setInitialSettings() { + automationType = autoTypeCmb.getText(); + updateFrequencyInMillis = updateFreqCmb.getText(); + } + + public String getAutomationType() { + return automationType; + } + + public String getUpdateFrequency() { + return updateFrequencyInMillis; + } + + @Override + protected boolean isResizable() { + return true; + } + + @Override + public boolean isHelpAvailable() { + return false; + } +} 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 345c0dd..a1f3ead 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,6 +1,11 @@ package oic.simulator.serviceprovider.view.dialogs; +import java.util.Iterator; +import java.util.Map; + +import oic.simulator.serviceprovider.Activator; import oic.simulator.serviceprovider.utils.Constants; +import oic.simulator.serviceprovider.utils.Utility; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; @@ -147,25 +152,24 @@ public class CreateResourcePage extends WizardPage { } private void populateResourceTypeCombo() { - /* - * List configList; configList = - * Activator.getDefault().getManager().getResourceConfigurationList(); - * if(null != configList) { Iterator itr = - * configList.iterator(); while(itr.hasNext()) { - * resourceTypeCmb.add(itr.next()); } } - */ - - // TODO: Temporarily adding a resourceType for testing - resourceTypeCmb.add("oic.light"); + Map configMap; + configMap = Activator.getDefault().getResourceManager() + .getResourceConfigurationList(); + if (null != configMap) { + Iterator itr = configMap.keySet().iterator(); + String fileName; + String shortName; + while (itr.hasNext()) { + fileName = itr.next(); + shortName = Utility.fileNameToDisplay(fileName); + System.out.println("Display name of " + fileName + " is " + + shortName); + resourceTypeCmb.add(shortName); + } + } // By default, selecting the first item in the resourceType combo - if (resourceTypeCmb.getItemCount() > 0) { - resourceTypeCmb.select(0); - // TODO: Get the RAML configuration file path of the selected - // resource - // configFilePath = - // Activator.getManager().getConfigFilePath(resourceTypeCmb.getItem(0)); - } + selectInitialItem(); } private void addUIListeners() { @@ -174,12 +178,7 @@ public class CreateResourcePage extends WizardPage { public void widgetSelected(SelectionEvent e) { // Set the configFilePath to the first item in the combo - if (resourceTypeCmb.getItemCount() > 0) - resourceTypeCmb.select(0); - - // TODO: Temporarily adding some random config file path - // To be removed after implementing resource configuration - configFilePath = "/Samplelight"; + selectInitialItem(); setPageComplete(isSelectionDone()); @@ -227,10 +226,17 @@ public class CreateResourcePage extends WizardPage { if (index >= 0) { String selectedItem = resourceTypeCmb.getItem(index); if (null != selectedItem) { - // TODO: Get the RAML configuration file path of the - // selected resource - // configFilePath = - // Activator.getDefault().getManager().getConfigFilePath(selectedItem); + // Convert the selectedItem to the fully qualified file + // name. + selectedItem = Utility.displayToFileName(selectedItem); + System.out + .println("Selected file name:" + selectedItem); + + // Get the RAML configuration file path of the selected + // resource + configFilePath = Activator.getDefault() + .getResourceManager() + .getConfigFilePath(selectedItem); setPageComplete(isSelectionDone()); } @@ -269,6 +275,18 @@ public class CreateResourcePage extends WizardPage { }); } + private void selectInitialItem() { + if (resourceTypeCmb.getItemCount() > 0) { + resourceTypeCmb.select(0); + String fileName = Utility.displayToFileName(resourceTypeCmb + .getText()); + System.out.println("Selected file in combo:" + fileName); + configFilePath = Activator.getDefault().getResourceManager() + .getConfigFilePath(fileName); + System.out.println("Selected file's path:" + configFilePath); + } + } + private boolean isSelectionDone() { boolean done = false; try { 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/dialogs/LogDetailsDialog.java similarity index 98% rename from service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogDetailsDialog.java rename to service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/LogDetailsDialog.java index c5d4e49..489dff4 100644 --- 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/dialogs/LogDetailsDialog.java @@ -1,4 +1,4 @@ -package oic.simulator.serviceprovider.view; +package oic.simulator.serviceprovider.view.dialogs; import java.text.DateFormat; import java.util.Date; -- 2.7.4