Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » warning dialog when editing property in properties sheet
warning dialog when editing property in properties sheet [message #418696] Thu, 24 April 2008 12:37 Go to next message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Hi,

For my editor a certain property may be set only once. For all subsequent
trials to change that property I would like to display a warning dialog
informing the user why he is not allowed to change that property.

I tried to do it in the following way:
I wrote my own ItemPropertyDescriptor and load it in the
addXXXPropertyDescriptor of the corresponding XXXItemProvider. Here my
CustomizedItemPropertyDescriptor:
public class CustomizedItemPropertyDescriptor extends
ItemPropertyDescriptor {

public CustomizedItemPropertyDescriptor(AdapterFactory adapterFactory,
ResourceLocator resourceLocator, String displayName,
String description, EStructuralFeature feature, boolean isSettable,
boolean multiLine, boolean sortChoices, Object staticImage,
String category, String[] filterFlags) {
super(adapterFactory, resourceLocator, displayName, description, feature,
isSettable, multiLine, sortChoices, staticImage, category,
filterFlags);
// TODO Auto-generated constructor stub
}

@Override
public void setPropertyValue(Object object, Object value) {
if(object instanceof Step){
String stepName = ((Step) object).getName();
if(stepName != null){
if(!stepName.equals(value)){
//set the name back to the old value
value = stepName;
//inform user
MessageDialog.openWarning(Display.getCurrent().getActiveShel l(), "Do
not rename Step Names", "Step Names for already existing Flow-Instances
can't be renamed. Renaming such a Step will probably cause multi-execution
of the same Step implementation.");
}//else name didn't change -> do nothing
}
}
super.setPropertyValue(object, value);
}
}

This works...but I also get an IllegalStateException since
DefaultOperationHistory.openOperation() is called twice. This topic was
discussed on the GMF forum already:
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg11716.html

The reason why I'm posting this here again is because I'm having problems
with the property sheet which is based in EMF. I think I'm using the wrong
hook. Can someone tell me how I can do it right?

Thank you for your help.

Greets,
Marsha
Re: warning dialog when editing property in properties sheet [message #418697 is a reply to message #418696] Thu, 24 April 2008 13:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Marsha,

Comments below.


Marsha wrote:
> Hi,
>
> For my editor a certain property may be set only once. For all
> subsequent trials to change that property I would like to display a
> warning dialog informing the user why he is not allowed to change that
> property.
Maybe you should make it read-only once it's been set. You could
include descriptive text in the status line.
>
>
> I tried to do it in the following way:
> I wrote my own ItemPropertyDescriptor and load it in the
> addXXXPropertyDescriptor of the corresponding XXXItemProvider. Here my
> CustomizedItemPropertyDescriptor:
> public class CustomizedItemPropertyDescriptor extends
> ItemPropertyDescriptor {
>
> public CustomizedItemPropertyDescriptor(AdapterFactory
> adapterFactory,
> ResourceLocator resourceLocator, String displayName,
> String description, EStructuralFeature feature, boolean
> isSettable,
> boolean multiLine, boolean sortChoices, Object staticImage,
> String category, String[] filterFlags) {
> super(adapterFactory, resourceLocator, displayName,
> description, feature,
> isSettable, multiLine, sortChoices, staticImage,
> category, filterFlags);
> // TODO Auto-generated constructor stub
> }
>
> @Override
> public void setPropertyValue(Object object, Object value) {
> if(object instanceof Step){
> String stepName = ((Step) object).getName();
> if(stepName != null){
> if(!stepName.equals(value)){
> //set the name back to the old value
> value = stepName;
> //inform user
>
> MessageDialog.openWarning(Display.getCurrent().getActiveShel l(), "Do
> not rename Step Names", "Step Names for already existing
> Flow-Instances can't be renamed. Renaming such a Step will probably
> cause multi-execution of the same Step implementation.");
> }//else name didn't change -> do nothing
> }
> }
Why set it at all if it hasn't changed?
> super.setPropertyValue(object, value);
> }
> }
>
> This works...but I also get an IllegalStateException since
> DefaultOperationHistory.openOperation() is called twice. This topic
> was discussed on the GMF forum already:
> http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg11716.html
>
> The reason why I'm posting this here again is because I'm having
> problems with the property sheet which is based in EMF. I think I'm
> using the wrong hook. Can someone tell me how I can do it right?
Maybe it's better to specialize canSetProperty to return false in this
case and include your warning text in the getDescription?
>
> Thank you for your help.
>
> Greets,
> Marsha
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: warning dialog when editing property in properties sheet [message #418766 is a reply to message #418697] Tue, 29 April 2008 08:11 Go to previous message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Hi Ed,

> Maybe it's better to specialize canSetProperty to return false in this
> case and include your warning text in the getDescription?

This works perfectly. Thank you for your help.

Marsha
Previous Topic:AdapterFactoryLabelProvider doesnt work in TableViewer
Next Topic:add "New Child" menu item without reference
Goto Forum:
  


Current Time: Fri Apr 26 10:07:46 GMT 2024

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

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

Back to the top