Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to change the order in which the properties are listed ?
How to change the order in which the properties are listed ? [message #551408] Fri, 06 August 2010 10:12 Go to next message
Syed Imran is currently offline Syed ImranFriend
Messages: 25
Registered: January 2010
Location: Cork, Ireland
Junior Member
Hi All,

In GMF editor "Show property view" all the properties are listed in ascending order by default. Is it possible to change their order?

regards,
Syed Imran
Re: How to change the order in which the properties are listed ? [message #551449 is a reply to message #551408] Fri, 06 August 2010 12:56 Go to previous messageGo to next message
Pantelis Petridis is currently offline Pantelis PetridisFriend
Messages: 10
Registered: February 2010
Junior Member
This is a multi-part message in MIME format.
--------------080007040807060801050700
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit


Hello,

in the two classes i attach the propertySheetPage represents a sheet
page which uses the custom propertySheetSorter to sort the attributes.
After you modify the sorter to your will, you need to create a third
class (e.g. MyAdvancedPropertySection) that extends the
AdvancedPropertySection and overrides the createControls method to
initialize a MyPropertySheetPage instead of the default
PropertySheetPage as the page member. Finally, you just set the
XXXPropertySection.java located in your XXX.diagram.sheet package to
extend the MyAdvancedPropertySection class.

Hope this helps,
Pantelis

On 6/8/2010 1:12 μμ, Syed Imran wrote:
> Hi All,
>
> In GMF editor "Show property view" all the properties are listed in
> ascending order by default. Is it possible to change their order?
>
> regards,
> Syed Imran
>


--------------080007040807060801050700
Content-Type: text/plain;
name="MyPropertySheetPage.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="MyPropertySheetPage.java"

cGFja2FnZSBvcmcuZWNsaXBzZS5nbWYuc25hcHQucHJvcGVydGllczsNCg0K aW1wb3J0IG9y
Zy5lY2xpcHNlLnVpLnZpZXdzLnByb3BlcnRpZXMuUHJvcGVydHlTaGVldFBh Z2U7DQppbXBv
cnQgb3JnLmVjbGlwc2UudWkudmlld3MucHJvcGVydGllcy5Qcm9wZXJ0eVNo ZWV0U29ydGVy
Ow0KDQpwdWJsaWMgY2xhc3MgTXlQcm9wZXJ0eVNoZWV0UGFnZSBleHRlbmRz IFByb3BlcnR5
U2hlZXRQYWdlIHsNCg0KICAgIHB1YmxpYyBNeVByb3BlcnR5U2hlZXRQYWdl KCkgew0KICAg
ICAgICBzdXBlcigpOw0KICAgICAgICBzZXRTb3J0ZXIobmV3IE15UHJvcGVy dHlTaGVldFNv
cnRlcigpKTsNCiAgICB9DQoNCiAgICBAT3ZlcnJpZGUNCiAgICBwcm90ZWN0 ZWQgdm9pZCBz
ZXRTb3J0ZXIoUHJvcGVydHlTaGVldFNvcnRlciBzb3J0ZXIpIHsNCiAgICAg ICAgaWYgKCEo
c29ydGVyIGluc3RhbmNlb2YgTXlQcm9wZXJ0eVNoZWV0U29ydGVyKSkNCiAg ICAgICAgICAg
IHNvcnRlciA9IG5ldyBNeVByb3BlcnR5U2hlZXRTb3J0ZXIoKTsNCg0KICAg ICAgICBzdXBl
ci5zZXRTb3J0ZXIoc29ydGVyKTsNCiAgICB9DQoNCn0gDQo=
--------------080007040807060801050700
Content-Type: text/plain;
name="MyPropertySheetSorter.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="MyPropertySheetSorter.java"

cGFja2FnZSBvcmcuZWNsaXBzZS5nbWYuc25hcHQucHJvcGVydGllczsNCg0K aW1wb3J0IGph
dmEudXRpbC5IYXNoTWFwOw0KDQppbXBvcnQgb3JnLmVjbGlwc2UudWkudmll d3MucHJvcGVy
dGllcy5JUHJvcGVydHlTaGVldEVudHJ5Ow0KaW1wb3J0IG9yZy5lY2xpcHNl LnVpLnZpZXdz
LnByb3BlcnRpZXMuUHJvcGVydHlTaGVldFNvcnRlcjsNCg0KcHVibGljIGNs YXNzIE15UHJv
cGVydHlTaGVldFNvcnRlciBleHRlbmRzIFByb3BlcnR5U2hlZXRTb3J0ZXIg ew0KDQoJQE92
ZXJyaWRlDQogICAgcHVibGljIHZvaWQgc29ydChJUHJvcGVydHlTaGVldEVu dHJ5W10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IgIiwg
IiIpKS5pbnRWYWx1ZSgpKSB7DQogICAgICAgIAkJCXN3YXBwZWQgPSB0cnVl Ow0KICAgICAg
ICAJCQlJUHJvcGVydHlTaGVldEVudHJ5IHRlbXAgPSBlbnRyaWVzW2pdOw0K ICAgICAgICAJ
CQllbnRyaWVzW2pdID0gZW50cmllc1tqKzFdOw0KICAgICAgICAJCQllbnRy aWVzW2orMV0g
PSB0ZW1wOw0KICAgICAgICAJCX0NCiAgICAgICAgCX0NCiAgICAgICAgCWlm KCFzd2FwcGVk
KSBicmVhazsNCiAgICAgICAgfQ0KICAgIH0NCg0KfQ0K
--------------080007040807060801050700--
Re: How to change the order in which the properties are listed ? [message #551486 is a reply to message #551449] Fri, 06 August 2010 15:16 Go to previous messageGo to next message
Syed Imran is currently offline Syed ImranFriend
Messages: 25
Registered: January 2010
Location: Cork, Ireland
Junior Member
Hi Pantelis,

Thanks, I am almost there.
The only thing is AdvancedPropertySection does not implement any methods then how to overrides the createControls method in a third class (e.g. MyAdvancedPropertySection).

kindy
Syed Imran
Re: How to change the order in which the properties are listed ? [message #551604 is a reply to message #551486] Sat, 07 August 2010 22:50 Go to previous messageGo to next message
Pantelis Petridis is currently offline Pantelis PetridisFriend
Messages: 10
Registered: February 2010
Junior Member
This is a multi-part message in MIME format.
--------------090602080507000809070108
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

hello,

i checked this out, i have created MyAdvancedPropertySection class which
is an exact copy of the original AdvancedPropertySection's code with the
only difference being that the "page" member is of MyPropertySheetPage
type. I attach it, if that helps

Pantelis

On 6/8/2010 6:16 μμ, Syed Imran wrote:
> Hi Pantelis,
>
> Thanks, I am almost there. The only thing is AdvancedPropertySection
> does not implement any methods then how to overrides the createControls
> method in a third class (e.g. MyAdvancedPropertySection).
>
> kindy
> Syed Imran


--------------090602080507000809070108
Content-Type: text/plain;
name="MyAdvancedPropertySection.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="MyAdvanc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AgICAgIE5vdGlmaWNhdGlvbkZpbHRlci5jcmVhdGVOb3RpZmllclR5 cGVGaWx0ZXIo
RU9iamVjdC5jbGFzcykpOw0KICAgIH0NCg0KICAgDQogICAgLyoNCgkgKiAo bm9uLUphdmFk
b2MpDQoJICogDQoJICogQHNlZSBvcmcuZWNsaXBzZS5nbWYucnVudGltZS5k aWFncmFtLnVp
LnByb3BlcnRpZXMuc2VjdGlvbnMuQWJzdHJhY3RNb2RlbGVyUHJvcGVydHlT ZWN0aW9uI2Fk
ZFRvRU9iamVjdExpc3QoamF2YS5sYW5nLk9iamVjdCkNCgkgKi8NCiAgICBw cm90ZWN0ZWQg
Ym9vbGVhbiBhZGRUb0VPYmplY3RMaXN0KE9iamVjdCBvYmplY3QpIHsNCiAg ICAgICAgLyog
bm90IGltcGxlbWVudGVkICovDQogICAgCXJldHVybiB0cnVlOw0KICAgIH0g IA0KDQp9
--------------090602080507000809070108--
Re: How to change the order in which the properties are listed ? [message #639501 is a reply to message #551604] Tue, 16 November 2010 18:47 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 16
Registered: July 2009
Junior Member
Hi Pantelis and Syed,

Pantelis, I have followed your instructions to implement my own sorting: I have created MyPropertySheetPage, MyPropertyShorter, MyAdvancedPropertySection and made MyPropertySection extend MyAdvancedPropertySection.

I just one to preserve the original order of the properties in the ecore model, don't need to do any additional ordering, but it is not working:

The "sort" method of MyPropertySorter is empty (in order to keep the original order), and it is correctly called, but it seems that properties have already been alphabetically ordered somewhere before. So I would need to reorder the properties of each object individually...

Any ideas?

By the way Pantelis, I cannot see the attachments you put on your messages... Could you please reattach them.

Thank you very much!
Re: How to change the order in which the properties are listed ? [message #645119 is a reply to message #639501] Wed, 15 December 2010 16:16 Go to previous message
Carlos  is currently offline Carlos Friend
Messages: 16
Registered: July 2009
Junior Member
Hi all,

After some time struggling with this problem, I have found a solution to preserve the order of the attributes in the properties view in a GMF generated diagram editor, as they are defined in the ecore model.

It is a bit long, but it is working fine. I leave it here just in case it is useful for anybody.

The key is that the alphabetical ordering is done not only in the PropertySheetSorter, but also in two places inside the PropertySheetEntry. So I have modified the code to remove this sortings.

So, to achieve this, it is necessary to use custom PropertySheetPage, PropertySheetSorter, and also PropertySheetEntry.

To do so, follow the next 5 steps:


1. Go to package: xxx.sheet inside the diagram plugin.

2. Create class XXXPropertySheetSorter as an extension of PropertySheetSorter, and override method sort(IPropertySheetEntry[] entries) to remove properties ordering, which is alphabetical.
The class code should result in something like this:

public class XXXPropertySheetSorter extends PropertySheetSorter
{
   public void sort(IPropertySheetEntry[] entries)
   {
   }
}


3. Create class XXXPropertySheetPage as an extension of PropertySheetPage, and override the constructor to use the XXXPropertySheetSorter created in the previous step:

public class XXXPropertySheetPage extends PropertySheetPage
{
   public XXXPropertySheetPage()
   {
      super();
      setSorter(new XXXPropertySheetSorter());
   }
}


4. Create class XXXPropertySheetEntry as an extension of UndoableModelPropertySheetEntry and override methods:

protected List computeMergedPropertyDescriptors();
protected Map computePropertyDescriptorsFor(IPropertySource source);


The code of both methods also does some ordering, so we remove that ordering in order to keep the original order.
The class would result in something like the following piece of code, where the important modifications are between "/////////////////////////////////////////////////////" (I could not find the way to color pieces of code):

public class XXXPropertySheetEntry extends UndoableModelPropertySheetEntry
{
   public XXXPropertySheetEntry(IOperationHistory operationHistory)
   {
      super(operationHistory);
   }

   /**
    * Overrides the super method to avoid ordering attributes, and so keep the
    * order defined in the ecore model.
    * 
    * @return sorted <code>List</code> of all the <code>IPropertyDescriptor</code>s for the objects 
    */
   protected List computeMergedPropertyDescriptors()
   {
      if (values.length == 0)
         return new ArrayList(0);

      // get all descriptors from each object
      Map[] propertyDescriptorMaps = new Map[values.length];
      for (int i = 0; i < values.length; i++)
      {
         Object object = values[i];
         IPropertySource source = getPropertySource(object);
         if (source == null)
         {
            // if one of the selected items is not a property source
            // then we show no properties
            return new ArrayList(0);
         }
         // get the property descriptors keyed by id
         propertyDescriptorMaps[i] = computePropertyDescriptorsFor(source);
      }

      // intersect
      Map intersection = propertyDescriptorMaps[0];
      for (int i = 1; i < propertyDescriptorMaps.length; i++)
      {
         // get the current ids
         Object[] ids = intersection.keySet().toArray();
         for (int j = 0; j < ids.length; j++)
         {
            Object object = propertyDescriptorMaps[i].get(ids[j]);
            if (object == null ||
            // see if the descriptors (which have the same id) are
                  // compatible
                  !((IPropertyDescriptor) intersection.get(ids[j])).isCompatibleWith((IPropertyDescriptor) object))
               intersection.remove(ids[j]);
         }
      }

      // Sort the descriptors
      List descriptors = new ArrayList(intersection.values());

////////////////////////////////////////////////////////////////////////
      // Commented to avoid alphabetically sorting of properties!
      //       Collections.sort(descriptors, new Comparator() {
      //           Collator coll = Collator.getInstance(Locale.getDefault());
      //
      //           public int compare(Object a, Object b) {
      //               IPropertyDescriptor d1, d2;
      //               String dname1, dname2;
      //               d1 = (IPropertyDescriptor) a;
      //               dname1 = d1.getDisplayName();
      //               d2 = (IPropertyDescriptor) b;
      //               dname2 = d2.getDisplayName();
      //               return coll.compare(dname1, dname2);
      //           }
      //       });
////////////////////////////////////////////////////////////////////////

      return descriptors;
   }

   /**
    * Overrides the super method to avoid ordering attributes, and so keep the
    * order defined in the ecore model.
    * The difference with the super method is that a LinkedHashMap is used instead of a HashMap,
    * in order to keep the properties order.
    * 
    * @param source a property source for which to obtain descriptors
    * @return a table of descriptors keyed on their id
    */
   protected Map computePropertyDescriptorsFor(IPropertySource source)
   {
      IPropertyDescriptor[] descriptors = source.getPropertyDescriptors();
      
////////////////////////////////////////////////////////////////////////
      // Use LinkedHashMap instead of HashMap to preserve order
      Map result = new LinkedHashMap();
////////////////////////////////////////////////////////////////////////
      for (int i = 0; i < descriptors.length; i++)
      {
         result.put(descriptors[i].getId(), descriptors[i]);
      }
      return result;
   }

}


5. We are almost done! Now, create class XXXAdvancedPropertySection as a copy of AdvancedPropertySection, and modify method createControls to use XXXPropertySheetPage and XXXPropertySheetEntry instead of the originals.
The resulting method is as follows, where the important modification are highlighted:

   public void createControls(final Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage)
   {
      super.createControls(parent, aTabbedPropertySheetPage);
      Composite composite = getWidgetFactory().createFlatFormComposite(parent);
      FormData data = null;

      String tableLabelStr = getTableLabel();
      CLabel tableLabel = null;
      if (tableLabelStr != null && tableLabelStr.length() > 0)
      {
         tableLabel = getWidgetFactory().createCLabel(composite, tableLabelStr);
         data = new FormData();
         data.left = new FormAttachment(0, 0);
         data.top = new FormAttachment(0, 0);
         tableLabel.setLayoutData(data);
      }

////////////////////////////////////////////////////////////////////////
      // Use VadPropertySheetPage to provide custom properties behavior
      page = new VadPropertySheetPage();
      
      // Use VadPropertySheetEntry to provide custom properties behavior
      UndoableModelPropertySheetEntry root = new VadPropertySheetEntry(OperationHistoryFactory.getOperationHistory());
////////////////////////////////////////////////////////////////////////

      root.setPropertySourceProvider(getPropertySourceProvider());
      page.setRootEntry(root);

      page.createControl(composite);
      data = new FormData();
      data.left = new FormAttachment(0, 0);
      data.right = new FormAttachment(100, 0);
      if (tableLabel == null)
      {
         data.top = new FormAttachment(0, 0);
      }
      else
      {
         data.top = new FormAttachment(tableLabel, 0, SWT.BOTTOM);
      }
      data.bottom = new FormAttachment(100, 0);
      data.height = 100;
      data.width = 100;
      page.getControl().setLayoutData(data);

      setActionBars(aTabbedPropertySheetPage.getSite().getActionBars());

   }



Carlos
Previous Topic:Error 'Received wrong transfer data.'
Next Topic:Programmatically hide one property from properties view
Goto Forum:
  


Current Time: Tue Apr 16 07:56:39 GMT 2024

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

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

Back to the top