+ @SuppressWarnings({ "unchecked", "deprecation" })
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
+ if (GraphExplorer.class == adapter)
+ return (T) tryGetExplorer(container);
+ if (BrowseContext.class == adapter)
+ return (T) tryGetBrowseContext(container);
+ return super.getAdapter(adapter);
+ }
+
+ private BrowseContext tryGetBrowseContext(Control control) {
+ return SWTUtils.tryGetObject(control, c -> {
+ return c instanceof IAdaptable
+ ? (BrowseContext) ((IAdaptable) c).getAdapter(BrowseContext.class)
+ : null;
+ });
+ }
+
+ private GraphExplorer tryGetExplorer(Control control) {
+ return SWTUtils.tryGetObject(control, c -> {
+ return c.isDisposed() ? null
+ : (GraphExplorer) c.getData(GraphExplorer.KEY_GRAPH_EXPLORER);
+ });
+ }
+