| Different properties for single and multiple selection in properties window [message #891712] |
Mon, 25 June 2012 11:10  |
ModelGeek Mising name Messages: 347 Registered: June 2011 |
Senior Member |
|
|
Hi,
I would like to have different properties available in properties view when multiple objects are selected. For example if one object is selected the it shows name property but when multiple objects are selected then name property should not be available as i want each object to have unique name.
Actually i have asked this question in RCP category but i have not got any answer so i thought may be this is the right place to ask this question
any idea how to acheive that?
Cheers,
|
|
|
| Re: Different properties for single and multiple selection in properties window [message #891728 is a reply to message #891712] |
Mon, 25 June 2012 11:58   |
|
try this ..
public class CustomPropertySheetEntry extends PropertySheetEntry{
@Override
protected IPropertySource getPropertySource(Object object) {
IPropertySource propertySource = super.getPropertySource(object);
boolean isMultiSelection = getValues().length > 1;
/*if (propertySource instance CustomModel) { // custom model implements IPropertySource
customModel.setMultiSelectionMode(isMultiSelection)
// inside custom model class getPropertyDescriptors() method
if (!isMultiSelection) {
//add single properties here like name
}
}*/
return propertySource;
}
/**
* In getAdapter method of view or editor
*
* if (type == IPropertySheetPage.class) {
PropertySheetPage propertySheetPage = new PropertySheetPage();
CustomPropertySheetEntry customPropertySheetEntry = new CustomPropertySheetEntry();
propertySheetPage.setRootEntry(customPropertySheetEntry);
return propertySheetPage;
}
*
*/
}
Regards,
Prasad
http://marketplace.eclipse.org/user/9964/listings
|
|
|
|
|
|
|
|
| Re: Different properties for single and multiple selection in properties window [message #892706 is a reply to message #892683] |
Fri, 29 June 2012 05:38   |
|
i found the problem.. by default the editor returns a undoable property sheeet entry
see this method.. which we have overridden with the custom one
org.eclipse.gef.ui.parts.GraphicalEditor.getAdapter(Class)
if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
PropertySheetPage page = new PropertySheetPage();
page.setRootEntry(new UndoablePropertySheetEntry(getCommandStack()));
return page;
}
but unfortunately UndoablePropertySheetEntry is a final class so i guess only way to do is create a copy of the UndoablePropertySheetEntry and override the getPropertySource()
Regards,
Prasad
http://marketplace.eclipse.org/user/9964/listings
|
|
|
|
| Re: Different properties for single and multiple selection in properties window [message #896191 is a reply to message #893371] |
Tue, 17 July 2012 10:13  |
ModelGeek Mising name Messages: 347 Registered: June 2011 |
Senior Member |
|
|
Hi,
Thanks for assitance. I have checked UndoablePropertySheetEntry is not final and i am using it
public class CustomPropertySheetEntry extends UndoablePropertySheetEntry {
public CustomPropertySheetEntry(CommandStack commandStack) {
super(commandStack);
}
@Override
protected IPropertySource getPropertySource(Object object) {
IPropertySource source = super.getPropertySource(object);
if(getValues()!=null && getValues().length>1) {
-----
}
else {
------
}
return source;
}
}
There is no compile time errors as UndoablePropertySheetEntry is not final but still my undo/redo buttons are disabled. So if a change any propety then undo/redo are not available but when i fous on editor then i have undo buttons available and i can undo the property change.
Any idea?
Cheers,
|
|
|
Powered by
FUDForum. Page generated in 0.02005 seconds