AW: AW: [udig-devel] objectProperty
Ingmar Eveslage
eveslage at gmail.com
Tue May 6 09:46:31 PDT 2008
Hello Jesse, helo Dirk,
thanks, This help. Realy a cool feature, this "objectProperty". It
realy cant be easier, if you understand it.
Greats Ingmar
Am 06.05.2008 um 14:30 schrieb Starke, Dirk:
> Hello Ingmar,
>
> it's just a couple of days ago when I faced that problem. Please
> have a look at http://udig.refractions.net/confluence/display/DEV/What+should+I+put+in+as+the+target+for+my+operation
>
> Here is a code snippet showing how to deal with the target object.
> It is configured to work on targetClass "java.lang.Object".
>
> public void op(Display display, Object target, IProgressMonitor
> monitor) throws Exception {
> if (target instanceof IMap) {
> IMap map = (IMap) target;
> IEditManager editManager = map.getEditManager();
> ILayer selectedLayer = editManager.getSelectedLayer();
> opOnLayer(display, selectedLayer, monitor);
> }
> else if (target instanceof ILayer) {
> opOnLayer(display, (ILayer) target, monitor);
> }
> else if (target instanceof IAdaptable) {
> ILayer layer = (ILayer) ((IAdaptable)
> target).getAdapter(ILayer.class);
> opOnLayer(display, layer, monitor);
> }
> else if (target instanceof Object[]) {
> Object[] targetArray = (Object[]) target;
> if (targetArray.length > 0) {
> Object realTarget = targetArray[0];
>
> if (realTarget instanceof IMap) {
> IMap map = (IMap) realTarget;
> IEditManager editManager = map.getEditManager();
> ILayer selectedLayer = editManager.getSelectedLayer();
> opOnLayer(display, selectedLayer, monitor);
> }
> else if (realTarget instanceof ILayer) {
> ILayer layer = (ILayer) realTarget;
> opOnLayer(display, layer, monitor);
> }
> else if (realTarget instanceof IAdaptable) {
> ILayer layer = (ILayer) ((IAdaptable)
> realTarget).getAdapter(ILayer.class);
> opOnLayer(display, layer, monitor);
> }
> }
> }
> else {
> final String MSG = "Data could not be identified.";
> display.syncExec(new ShowMessageDialogRunnable(display,
> "uDIGEval", MSG,
> MessageDialog.INFORMATION));
> }
> }
>
> Hope this helps.
>
> Regards,
> Dirk
>
>
> -----Ursprüngliche Nachricht-----
> Von: udig-devel-bounces at lists.refractions.net
> [mailto:udig-devel-bounces at lists.refractions.net]Im Auftrag von Jesse
> Eichar
> Gesendet: Dienstag, 6. Mai 2008 08:42
> An: User-friendly Desktop Internet GIS
> Betreff: Re: AW: [udig-devel] objectProperty
>
>
> Hi, The way that eclipse work is most plugins are lazily loaded.
> Only the XML is loaded. So the more information you can put in the
> xml the later the plugin can be loaded which both increases memory and
> takes time.
>
> So the idea with target class is to look at the current selection and
> see all the elements in the selection are of the target class type.
> For example if you have a property that requires a layer to validate
> its property then you put ILayer as the target property. This way if
> a map is selected then the property plugin won't be called and the
> property won't be called... Or rather it will automatically resolve to
> false.
>
> So I guess it has 2 purposes. 1. Improve performance and 2. declare
> what objects can be passed to the property object.
>
> Jesse
>
>
> On 5-May-08, at 7:20 PM, Ingmar Eveslage wrote:
>
>> Hello Dirk, hello Jesse,
>>
>> thanks. This works. realy a bit confusing, but it worked.
>>
>> Can you explain me, what the target class is? or exactly which
>> objects gets evaluated against the property class?
>>
>> i tried, java.lang.Object and net.refractions.udig.project.ILayer.
>> The second i copied from the udig project. it works realy good, but
>> who managed the objects which are put in the
>>
>> public boolean isTrue(ILayer object, String value)
>>
>> function?
>>
>> <object
>> targetClass="java.lang.Object">
>> <property
>>
>> class="de.hub.sam.es.managementclient.tool.StationProperty"
>> id="isStationProperty">
>> </property>
>> </object>
>> <object
>> targetClass="net.refractions.udig.project.ILayer">
>> <property
>>
>> class="de.hub.sam.es.managementclient.tool.LayerFeatureTypeProperty"
>> id="LayerFeatureTypeProperty">
>> </property>
>> </object>
>>
>> thanks for explaining.
>>
>> greats ingmar
>>
>> Am 05.05.2008 um 12:03 schrieb Starke, Dirk:
>>
>>> Hello Ingmar,
>>>
>>> you have to reference your property including the full path of your
>>> plugin.
>>>
>>> Example: Let's say your plugin's name is "my.udig.plugin", then
>>> (even when referencing a property declared in the same plugin) you
>>> have to write the following:
>>>
>>> ...
>>> <enablement>
>>> <property
>>> expectedValue="StationFeatureType"
>>> propertyId="my.udig.plugin.isStationProperty">
>>> </property>
>>> </enablement>
>>> ...
>>>
>>> Regards,
>>> Dirk
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: udig-devel-bounces at lists.refractions.net
>>> [mailto:udig-devel-bounces at lists.refractions.net]Im Auftrag von
>>> Ingmar
>>> Eveslage
>>> Gesendet: Sonntag, 4. Mai 2008 01:18
>>> An: User-friendly Desktop Internet GIS
>>> Betreff: [udig-devel] objectProperty
>>>
>>>
>>> Hello,
>>>
>>> first: i use the sdk rc14
>>>
>>> i try to implement a extension for
>>> net.refractions.udig.project.ui.tool. this should only be enabled if
>>> some conditions a true. so i tried to implement this.
>>>
>>> the plugin.xml:
>>>
>>> <extension
>>> point="net.refractions.udig.project.ui.tool">
>>> <actionTool
>>> class=".managementclient.tool.LeaderNodeAction"
>>> icon="icons/16x16/leader.png"
>>> id="managementclient.tool.LeaderNodeAction"
>>> name="LeaderSelection"
>>> onToolbar="true"
>>> tooltip="switch leader entity on/off">
>>> <enablement>
>>> <property
>>> expectedValue="StationFeatureType"
>>> propertyId="isStationProperty">
>>> </property>
>>> </enablement>
>>> </actionTool>
>>> </extension>
>>>
>>> <extension
>>> point="net.refractions.udig.ui.objectProperty">
>>> <object
>>> targetClass="java.lang.Object">
>>> <property
>>> class="managementclient.tool.StationProperty"
>>> id="isStationProperty">
>>> </property>
>>> </object>
>>> </extension>
>>>
>>> a very early implementation of the objectProperty interface:
>>>
>>> package managementclient.tool;
>>>
>>> import net.refractions.udig.project.ui.ApplicationGIS;
>>> import net.refractions.udig.ui.operations.AbstractPropertyValue;
>>> import net.refractions.udig.ui.operations.PropertyValue;
>>>
>>> @SuppressWarnings("unchecked")
>>> public class StationProperty extends AbstractPropertyValue
>>> implements
>>> PropertyValue {
>>>
>>> public StationProperty() {
>>> // TODO Auto-generated constructor stub
>>> }
>>>
>>> public boolean canCacheResult() {
>>> // TODO Auto-generated method stub
>>> return false;
>>> }
>>>
>>> public boolean isBlocking() {
>>> // TODO Auto-generated method stub
>>> return false;
>>> }
>>>
>>> public boolean isTrue(Object object, String value) {
>>> if (ApplicationGIS.getActiveMap()==ApplicationGIS.NO_MAP)
>>> return false;
>>> return true;
>>> }
>>> }
>>>
>>> The problem is: when i start i get this error message and the tool
>>> is
>>> always on:
>>>
>>> !ENTRY net.refractions.udig.ui 1 0 2008-05-04 01:09:31.152
>>> !MESSAGE PropertyParser: Parsing PropertyValue, desired Propert:
>>> isStationProperty not found. Referenced in plugin: managementclient
>>>
>>> what is going wrong? i hope somebody has an idea.
>>>
>>> Thanks forward
>>>
>>> Ingmar
>>> _______________________________________________
>>> User-friendly Desktop Internet GIS (uDig)
>>> http://udig.refractions.net
>>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>> _______________________________________________
>>> User-friendly Desktop Internet GIS (uDig)
>>> http://udig.refractions.net
>>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
More information about the udig-devel
mailing list