Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Creating a "Mini" View
Creating a "Mini" View [message #1004310] Wed, 23 January 2013 00:39 Go to next message
Tim E. is currently offline Tim E.Friend
Messages: 56
Registered: November 2012
Member
Hi,

it's me again, and I'm having another problem Sad

At the moment I'm trying to create a new view for my GEF-based editor,
showing a miniature version of the diagram displayed.

I found a miniature view in the logic example,
although I don't yet how to transfer it to its own view.

But my problem at the moment starts a lot earlier.

I defined a new view in the plugins.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.editors">
      <editor
            class="controller.CDGraphicsEditor"
            contributorClass="[path to class].GenericActionBarContributor"
            default="false"
            extensions="cd"
            id="cdGraphics"
            name="cdGraphics">
      </editor>
   </extension>
   <extension
         point="org.eclipse.ui.views">
      <view
            class="[path to class].controller.views.minipreview.MiniView"
            id="cdGraphics.miniView"
            name="cdGraphics.miniView"
            restorable="true">
      </view>
   </extension>
</plugin>


And for testing purposes I implemented the following View according to this tutorial like this:
public class MiniView extends ViewPart {
  
  private Label label;
  
  public MiniView() {
  }
  
  @Override
  public void createPartControl(Composite parent) {
    label = new Label(parent, 0);
    label.setText("Hello World");
  }
  
  @Override
  public void setFocus() {
    label.setFocus();
  }
}


Unfortunately, I cannot open this view.
I cannot find my view under "Window -> Show View -> other..."

And I have no idea, why this does not work.

I would appreciate any help and advices on

1) How to make this view visible

2) Perhaps an idea how to implement the "Mini" View or more detailed:
How to pass my existing GraphicalViewer or RootEditPart to this view...

I'd appreciate any help...

Thanks a lot,
Tim
Re: Creating a "Mini" View [message #1004723 is a reply to message #1004310] Wed, 23 January 2013 18:38 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4425
Registered: July 2009
Senior Member

When you find that changes to the plugin.xml files aren't picked up, check your Eclipse Application launcher. More than likely it's not been set to clear the configuration space from its Configuration tab.


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Creating a "Mini" View [message #1004743 is a reply to message #1004723] Wed, 23 January 2013 19:42 Go to previous messageGo to next message
Tim E. is currently offline Tim E.Friend
Messages: 56
Registered: November 2012
Member
Thanks for the hint...

I accomplished to see the view by now!

Now I'm trying to solve my second problem: to access the GraphicalViewer from my view, since I don't want to put it directly as a class in my Editor.

Cheers,
Tim

[Updated on: Wed, 23 January 2013 19:42]

Report message to a moderator

Re: Creating a "Mini" View [message #1005032 is a reply to message #1004743] Thu, 24 January 2013 10:59 Go to previous message
Tim E. is currently offline Tim E.Friend
Messages: 56
Registered: November 2012
Member
I accomplished to solve my second problem as well.

In my View class I make use of a IPartListener2.

The code looks like this:

  // The listener
  private class ChangeListener implements IPartListener2 {
    @Override
    public void partActivated(IWorkbenchPartReference ref) {
      if (ref.getPart(false) instanceof <EditorClass>) {
        <EditorClass>editor = (<EditorClass>) ref.getPart(false);
        viewer = (GraphicalViewer) editor.getAdapter(GraphicalViewer.class);
        refreshContents();
      }
    }
    ..a lot more methods..
  }

  // refreshContents method of Overview View
  private void refreshContents() {
    if (viewer != null) {
      // miniature view
      thumbnail = new ScrollableThumbnail((Viewport) ((ScalableRootEditPart) viewer.getRootEditPart()).getFigure());
      thumbnail.setSource(((ScalableRootEditPart) viewer.getRootEditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS));
      lws.setContents(thumbnail);
      disposeListener = new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
          if (thumbnail != null) {
            thumbnail.deactivate();
            thumbnail = null;
          }
        }
      };
      viewer.getControl().addDisposeListener(disposeListener);
    }
  }

// registration of listener in constructor
  IWorkbenchWindow wbw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  page = wbw.getActivePage();
  changeListener = new ChangeListener();
  page.addPartListener(changeListener);


I'm not sure if this is the best solution, but at least it works.
If you have suggestions or remarks, feel free to tell me Smile

If you need more code or explanation of my solution, let me also know.

Cheers,
Tim
Previous Topic:Displaying Connections
Next Topic:Troubles with layouts
Goto Forum:
  


Current Time: Tue Mar 19 05:40:45 GMT 2024

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

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

Back to the top