Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How do I get notifications on changes of resource properties
How do I get notifications on changes of resource properties [message #121847] Wed, 03 September 2003 07:57 Go to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Hi all,

I have a property page that is displayed for certain resources and sets a
persistent property on the resource. I also have an editor that queries this
resource property and behaves slightly differently in terms of
syntax-highlighting and auto-completion depending on the value of the property.

Now, I'd like the editor to effectively listen to changes of the property,
so that the user doesn't need to re-open the editor after changing the
property. However I couldn't find an API to accomplish this.
IResourceChangeListeners don't seem to be notified when a property is changed.

Am I missing something, or is this simply not possible? (and in case of the
latter, why not?)

-chris
Re: How do I get notifications on changes of resource properties [message #121975 is a reply to message #121847] Wed, 03 September 2003 09:43 Go to previous messageGo to next message
Eclipse UserFriend
I just guessed... and searched for IPropertyChangeListener:

http://www.eclipse.org/search/search.cgi?q=IPropertyChangeLi stener

Chris

<user@domain.invalid> wrote in message news:bj4kp9$94v$1@eclipse.org...
> Hi all,
>
> I have a property page that is displayed for certain resources and sets a
> persistent property on the resource. I also have an editor that queries
this
> resource property and behaves slightly differently in terms of
> syntax-highlighting and auto-completion depending on the value of the
property.
>
> Now, I'd like the editor to effectively listen to changes of the property,
> so that the user doesn't need to re-open the editor after changing the
> property. However I couldn't find an API to accomplish this.
> IResourceChangeListeners don't seem to be notified when a property is
changed.
>
> Am I missing something, or is this simply not possible? (and in case of
the
> latter, why not?)
>
> -chris
>
Re: How do I get notifications on changes of resource properties [message #122002 is a reply to message #121975] Wed, 03 September 2003 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Chris Laffra wrote:
> I just guessed... and searched for IPropertyChangeListener:
>
> http://www.eclipse.org/search/search.cgi?q=IPropertyChangeLi stener

However, IPropertyChangeListener doesn't have anything to do with resources.
It is used for listening to preference store changes etc. And it's a UI
interface. I cannot register an IPropertyChangeListener with a resource or
the workspace (all IIUC).

-chris

> <user@domain.invalid> wrote in message news:bj4kp9$94v$1@eclipse.org...
>
>>Hi all,
>>
>>I have a property page that is displayed for certain resources and sets a
>>persistent property on the resource. I also have an editor that queries
>
> this
>
>>resource property and behaves slightly differently in terms of
>>syntax-highlighting and auto-completion depending on the value of the
>
> property.
>
>>Now, I'd like the editor to effectively listen to changes of the property,
>>so that the user doesn't need to re-open the editor after changing the
>>property. However I couldn't find an API to accomplish this.
>>IResourceChangeListeners don't seem to be notified when a property is
>
> changed.
>
>>Am I missing something, or is this simply not possible? (and in case of
>
> the
>
>>latter, why not?)
>>
>>-chris
Re: How do I get notifications on changes of resource properties [message #122041 is a reply to message #121847] Wed, 03 September 2003 10:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: didier.besset.ch.sogeti.biz

Your class must implement IResourceChangeListener which consists of a
single method resourceChanged. There is a bunch of utility which allow you
to navigate through the changes.

I append an example of code using all this. Please refer to the Javadoc of
the classes for further details.

Cheers,

Didier


public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta().findMember(
model.getContainer().getFullPath());
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor( model);
model.removeChangeListener( this);
try {
delta.accept( visitor);
if ( visitor.hasRequestedClose() ) {
Display display= getSite().getShell().getDisplay();
display.asyncExec(new Runnable() {
public void run() {
if (localeViewer != null) {
// check whether editor has not been disposed yet
getSite().getPage().closeEditor( TranslationworkshopEditor.this,
false);
}
}
});
} else if ( visitor.hasDetectedChanges() ) {
Display.getDefault().asyncExec( new Runnable() {
public void run() {
keysViewer.setInput( null);
localeViewer.setInput( model);
}});
resetUndoRedoCommands();
}
} catch (CoreException e) {
setErrorMessage(
TextManager.getTranslatedText(TextManager.RUN_TIME_ERROR) +
e.getMessage());
e.printStackTrace();
} finally {
model.addChangeListener( this);
}
}


user@domain.invalid wrote:

> Hi all,

> I have a property page that is displayed for certain resources and sets a
> persistent property on the resource. I also have an editor that queries this
> resource property and behaves slightly differently in terms of
> syntax-highlighting and auto-completion depending on the value of the
property.

> Now, I'd like the editor to effectively listen to changes of the property,
> so that the user doesn't need to re-open the editor after changing the
> property. However I couldn't find an API to accomplish this.
> IResourceChangeListeners don't seem to be notified when a property is
changed.

> Am I missing something, or is this simply not possible? (and in case of the
> latter, why not?)

> -chris
Re: How do I get notifications on changes of resource properties [message #122080 is a reply to message #122041] Wed, 03 September 2003 10:45 Go to previous messageGo to next message
Eclipse UserFriend
Didier Besset wrote:
> Your class must implement IResourceChangeListener which consists of a
> single method resourceChanged. There is a bunch of utility which allow you
> to navigate through the changes.

Hmm, this is what I thought and tried. However, when I attach my
IResourceChangeListener to the workspace, it never gets called for property
changes (it does get called for content changes etc). Any ideas?

-chris
Re: How do I get notifications on changes of resource properties [message #122115 is a reply to message #122002] Wed, 03 September 2003 10:56 Go to previous messageGo to next message
Eclipse UserFriend
All you can do to track property changes on resources is to poll the
resource and see if its persistent property has changed.
No change listeners on this one. Code like this might work:

void trackResourceProperty(final IResource resource, final QualifiedName
propertyName, final Runnable listener) {
new Thread(new Runnable() {
public void run() {
try {
String value =
resource.getPersistentProperty(propertyName);
while (true) {
try { Thread.sleep(1000); } catch (Exception e) { }
String newValue =
resource.getPersistentProperty(propertyName);
if (!value.equals(newValue)) {
listener.run();
value = newValue;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}



Chris

"Christopher Lenz" <cmlenz@gmx.de> wrote in message
news:bj4rtg$hrl$1@eclipse.org...
> Chris Laffra wrote:
> > I just guessed... and searched for IPropertyChangeListener:
> >
> > http://www.eclipse.org/search/search.cgi?q=IPropertyChangeLi stener
>
> However, IPropertyChangeListener doesn't have anything to do with
resources.
> It is used for listening to preference store changes etc. And it's a UI
> interface. I cannot register an IPropertyChangeListener with a resource or
> the workspace (all IIUC).
>
> -chris
>
> > <user@domain.invalid> wrote in message news:bj4kp9$94v$1@eclipse.org...
> >
> >>Hi all,
> >>
> >>I have a property page that is displayed for certain resources and sets
a
> >>persistent property on the resource. I also have an editor that queries
> >
> > this
> >
> >>resource property and behaves slightly differently in terms of
> >>syntax-highlighting and auto-completion depending on the value of the
> >
> > property.
> >
> >>Now, I'd like the editor to effectively listen to changes of the
property,
> >>so that the user doesn't need to re-open the editor after changing the
> >>property. However I couldn't find an API to accomplish this.
> >>IResourceChangeListeners don't seem to be notified when a property is
> >
> > changed.
> >
> >>Am I missing something, or is this simply not possible? (and in case of
> >
> > the
> >
> >>latter, why not?)
> >>
> >>-chris
>
Re: How do I get notifications on changes of resource properties [message #122139 is a reply to message #122115] Wed, 03 September 2003 11:14 Go to previous messageGo to next message
Eclipse UserFriend
Chris Laffra wrote:
> All you can do to track property changes on resources is to poll the
> resource and see if its persistent property has changed.
> No change listeners on this one.

Okay, thanks. I'll just need to introduce some object through which all
modifications of my resource property are made, and allow attaching
listeners to that object. Not a big issue.

-chris
Re: How do I get notifications on changes of resource properties [message #122205 is a reply to message #122139] Wed, 03 September 2003 11:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

You can also open a feature request in bugzilla against Platform - CORE.

Simon :-)

"Christopher Lenz" <cmlenz@gmx.de> wrote in message
news:bj50aa$n47$1@eclipse.org...
> Chris Laffra wrote:
> > All you can do to track property changes on resources is to poll the
> > resource and see if its persistent property has changed.
> > No change listeners on this one.
>
> Okay, thanks. I'll just need to introduce some object through which all
> modifications of my resource property are made, and allow attaching
> listeners to that object. Not a big issue.
>
> -chris
>
Re: How do I get notifications on changes of resource properties [message #122608 is a reply to message #122205] Thu, 04 September 2003 06:55 Go to previous message
Eclipse UserFriend
Simon Arsenault wrote:
> You can also open a feature request in bugzilla against Platform - CORE.

For the record:

,----------------------------------------------------------- ----------
| "Persistent properties are intended to be used only by the plug-in
| that declares them. One plug-in should *not* get/set properties that
| belong to another plug-in. So, there is no benefit (across plugin
| boundaries) in generating events if the only interested party is
| exactly who is executing the modification."
`----------------------------------------------------------- ----------
[http://bugs.eclipse.org/bugs/show_bug.cgi?id=42461]

> Simon :-)
>
> "Christopher Lenz" <cmlenz@gmx.de> wrote in message
> news:bj50aa$n47$1@eclipse.org...
>
>>Chris Laffra wrote:
>>
>>>All you can do to track property changes on resources is to poll the
>>>resource and see if its persistent property has changed.
>>>No change listeners on this one.
>>
>>Okay, thanks. I'll just need to introduce some object through which all
>>modifications of my resource property are made, and allow attaching
>>listeners to that object. Not a big issue.
>>
>>-chris
Previous Topic:Extending the Navigator?
Next Topic:Auto-load plugins
Goto Forum:
  


Current Time: Thu Jul 10 09:53:36 EDT 2025

Powered by FUDForum. Page generated in 0.07222 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top