Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Show Properties View in Context Menu
Show Properties View in Context Menu [message #890321] Thu, 21 June 2012 18:49 Go to next message
Benjamin Klatt is currently offline Benjamin Klatt
Messages: 35
Registered: September 2010
Member
Hi,

I am working on a Graphiti Diagram Editor and would like to add an option to the context menu to show a selected element in the Properties View. The functionality should be the same as in the default ecore diagram editors. In the documentation and in the forum I just found information about how to extend the tabbed properties view, but no hint how to open a view from a graphiti feature execute method.
So any hint is welcome!

Thanks
Benjamin
Re: Show Properties View in Context Menu [message #891352 is a reply to message #890321] Sun, 24 June 2012 15:33 Go to previous message
Aljoscha Hark is currently offline Aljoscha Hark
Messages: 24
Registered: March 2012
Junior Member
hi,

i think it is appropriate to implement this in a custom feature as described in [1].

e.g. you could create the following feature:
public class ShowPropertiesViewFeature extends AbstractCustomFeature {
   private static final String VIEW_ID = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$

   public ShowPropertiesViewFeature(IFeatureProvider fp) {
      super(fp);
   }

   @Override
   public boolean canExecute(ICustomContext context) {
      return true;
   }

   @Override
   public String getName() {
      return "Show Properties View";
   }

   @Override
   public String getImageId() {
      return ImageProvider.VIEW_PROPERTIES;
   }

   @Override
   public void execute(ICustomContext context) {
      if (PlatformUI.isWorkbenchRunning()) {
         IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
         if (window != null) {
            IWorkbenchPage page = window.getActivePage();
            if (page != null) {
               try {
                  page.showView(VIEW_ID);
               } catch (PartInitException e) {
                  e.printStackTrace();
               }
            }
         }
      }
   }

   @Override
   public boolean hasDoneChanges() {
      return false;
   }
}


in your feature provider, override getCustomFeatures(ICustomContext):
private ICustomFeature showPropertiesViewFeature;

@Override
public ICustomFeature[] getCustomFeatures(ICustomContext context) {
   Collection<ICustomFeature> features = new ArrayList<ICustomFeature>();

   features.add(getShowPropertiesFeature());

   // others...

   return features.toArray(new ICustomFeature[features.size()]);
}

private ICustomFeature getShowPropertiesFeature() {
   if (showPropertiesViewFeature == null) {
      showPropertiesViewFeature = new ShowPropertiesViewFeature(this);
   }
   return showPropertiesViewFeature;
}


greets,
aljoscha

[1] (add http) help.eclipse.org/indigo/topic/org.eclipse.graphiti.doc/resources/docu/gfw/custom-feature.htm
Previous Topic:Problem Marker deleted at diagram opening
Next Topic:recommended way to group updates?
Goto Forum:
  


Current Time: Thu Apr 17 11:29:55 EDT 2014

Powered by FUDForum. Page generated in 0.03677 seconds