private void init() { final Map<URI, Map<String, String>> extensionURIS = getExtensionURIS(); for (final URI uri : extensionURIS.keySet()) { final Resource resource = loadResource(uri); final EObject eObject = resource.getContents().get(0); if (!(eObject instanceof VView)) { // TODO:log continue; } final VView view = (VView) eObject; if (view.getRootEClass() == null) { // TODO:log continue; } if (!map.containsKey(view.getRootEClass())) { map.put(view.getRootEClass(), new LinkedHashMap<VView, Map<String, String>>()); } map.get(view.getRootEClass()).put(view, extensionURIS.get(uri)); } }
@Override public void selectionChanged(SelectionChangedEvent event) { final Object treeSelected = ((IStructuredSelection) event.getSelection()).getFirstElement(); final Object selected = treeSelected == null ? treeSelected : manipulateSelection(treeSelected); if (selected instanceof EObject) { try { if (childComposite != null) { childComposite.dispose(); cleanCustomOnSelectionChange(); } childComposite = createComposite(); final Object root = manipulateSelection( ((RootObject) ((TreeViewer) event.getSource()).getInput()).getRoot()); final VElement viewModel = getViewModelContext().getViewModel(); final VViewModelProperties properties = ViewModelPropertiesHelper.getInhertitedPropertiesOrEmpty(viewModel); properties.addNonInheritableProperty(DETAIL_KEY, true); final boolean rootSelected = selected.equals(root); if (rootSelected) { properties.addNonInheritableProperty(ROOT_KEY, true); } VView view = null; if (rootSelected) { view = getVElement().getDetailView(); } if (view == null || view.getChildren().isEmpty()) { view = ViewProviderHelper.getView((EObject) selected, properties); } final ReferenceService referenceService = getViewModelContext().getService(ReferenceService.class); final ViewModelContext childContext = getViewModelContext() .getChildContext( (EObject) selected, getVElement(), view, new TreeMasterDetailReferenceService(referenceService)); manipulateViewContext(childContext); ECPSWTViewRenderer.INSTANCE.render(childComposite, childContext); relayoutDetail(); } catch (final ECPRendererException e) { Activator.getDefault() .getReportService() .report( new StatusReport( new Status( IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e))); } } }