Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Different properties for single and multiple selection in properties window
Different properties for single and multiple selection in properties window [message #891712] Mon, 25 June 2012 11:10 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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;
		}
	 * 
	 */
	
}

Re: Different properties for single and multiple selection in properties window [message #891923 is a reply to message #891728] Tue, 26 June 2012 11:15 Go to previous messageGo to next message
Eclipse UserFriend
thanks for assistance!
Re: Different properties for single and multiple selection in properties window [message #891924 is a reply to message #891728] Tue, 26 June 2012 11:16 Go to previous messageGo to next message
Eclipse UserFriend
thanks!
Re: Different properties for single and multiple selection in properties window [message #892523 is a reply to message #891728] Thu, 28 June 2012 10:25 Go to previous messageGo to next message
Eclipse UserFriend
Hi,


It worked but now UNDO and REDO buttons are disabled.

Do you have any idea why it is ?

Cheers,
Re: Different properties for single and multiple selection in properties window [message #892534 is a reply to message #892523] Thu, 28 June 2012 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Not sure.. ideally this should not affect the undo/redo .. did you check by commenting the multiselection part and see if the undo/redo is working? btw where are you using these properties in a gef based editor or something else?
Re: Different properties for single and multiple selection in properties window [message #892683 is a reply to message #892534] Fri, 29 June 2012 03:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Yes i am using GEF editors and i have tried commenting the newly added code for CustomerPropertyEntry and UNDO and REDO works.

cheers,
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 Go to previous messageGo to next message
Eclipse UserFriend
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()
Re: Different properties for single and multiple selection in properties window [message #893371 is a reply to message #892683] Tue, 03 July 2012 13:52 Go to previous messageGo to next message
Eclipse UserFriend
i think this is a much better and cleaner way to solve this problem which was answered in the other post http://www.eclipse.org/forums/index.php/mv/msg/365224/892824/#msg_892824

[Updated on: Tue, 03 July 2012 13:52] by Moderator

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 Go to previous message
Eclipse UserFriend
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,
Previous Topic:Save Button in RCP Product
Next Topic:eclipse headless junit test framework
Goto Forum:
  


Current Time: Wed Jul 23 00:34:26 EDT 2025

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

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

Back to the top