@Override public void partActivated(IWorkbenchPart part) { if (part instanceof MapEditor) { MapEditor editor = (MapEditor) part; // deactive current viewer if (activeViewer != null) { // FIXME save state } // activate/create activeViewer = viewers.get(editor.getMap().id()); if (activeViewer == null) { activeViewer = new ToolingViewer(editor); activeViewer.createControl(parent); viewers.put(editor.getMap().id(), activeViewer); } layout.topControl = activeViewer.getControl(); // activeViewer.getControl().pack( true ); parent.pack(true); Polymap.getSessionDisplay() .asyncExec( new Runnable() { public void run() { if (!parent.isDisposed() && !parent.getParent().isDisposed()) { parent.getParent().layout(true); } } }); } }
@Override public void partClosed(IWorkbenchPart part) { if (part instanceof MapEditor) { MapEditor editor = (MapEditor) part; ToolingViewer viewer = viewers.remove(editor.getMap().id()); viewer.dispose(); if (viewer == activeViewer) { activeViewer = null; } parent.pack(true); Polymap.getSessionDisplay() .asyncExec( new Runnable() { public void run() { parent.getParent().layout(true); } }); } }