Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.76 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Eclipse RCP nested properties
  2. public Object getPropertyValue(Object id) {
  3.     if (id.equals("POSITION")) {
  4.         return (IPropertySource) tablePosition;
  5.     }
  6.     return null;
  7. }
  8.        
  9. public class TablePosition implements IPropertySource
  10.        
  11. @Override
  12.     public Object getEditableValue() {
  13.         return this;
  14.     }
  15.  
  16.     @Override
  17.     public IPropertyDescriptor[] getPropertyDescriptors() {
  18.         return desc;
  19.     }
  20.  
  21.     @Override
  22.     public Object getPropertyValue(Object id) {
  23.         if ("X".equals(id)) {
  24.             return String.valueOf(x);
  25.         } else if ("Y".equals(id)) {
  26.             return String.valueOf(y);
  27.         } else if ("WIDTH".equals(id)) {
  28.             return String.valueOf(spanX);
  29.         } else if ("HEIGHT".equals(id)) {
  30.             return String.valueOf(spanY);
  31.         } else if ("ALIGN_H".equals(id)) {
  32.             switch (alignH) {
  33.             case LEFT:
  34.                 return "left";
  35.             case RIGHT:
  36.                 return "right";
  37.             default:
  38.                 return "center";
  39.             }
  40.         } else if ("ALIGN_V".equals(id)) {
  41.             switch (alignV) {
  42.             case TOP:
  43.                 return "top";
  44.             case BOTTOM:
  45.                 return "bottom";
  46.             default:
  47.                 return "middle";
  48.             }
  49.         }
  50.         return null;
  51.     }
  52.  
  53.     @Override
  54.     public boolean isPropertySet(Object id) {
  55.         return true;
  56.     }
  57.  
  58.     @Override
  59.     public void resetPropertyValue(Object id) {
  60.  
  61.     }
  62.  
  63.     @Override
  64.     public void setPropertyValue(Object id, Object value) {
  65.         if ("X".equals(id)) {
  66.             x = Integer.parseInt(value.toString());
  67.         } else if ("Y".equals(id)) {
  68.             y = Integer.parseInt(value.toString());
  69.         }
  70.         firePropertyChange("", null, null);
  71.     }