Skip to main content


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 22:49 Go to next message
Benjamin Klatt is currently offline Benjamin KlattFriend
Messages: 36
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 19:33 Go to previous message
Aljoscha Hark is currently offline Aljoscha HarkFriend
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: Tue Apr 16 08:47:58 GMT 2024

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

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

Back to the top