Let a view show the details for selected entries of two other views in rcp e4

My application contains three views: On the left side view “A” and view “B” each with a list of table entries and on the right side the view “Details” that shows the details for the selected entries of view “A” or view “B” depending on which view was activated as last on the left side.

It works with rcp3 but I can’t find an equivalent solution for rcp e4.

In rcp3 it is implemented with the workbench site selection provider like this:

ViewA:

public void createPartControl(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setInput(Arrays.asList("A1", "A2", "A3"));

    getSite().setSelectionProvider(viewer);
}

ViewB:

public void createPartControl(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setInput(Arrays.asList("B1", "B2", "B3"));
        
    getSite().setSelectionProvider(viewer);
}

DetailsView:

public void createPartControl(Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));
    detailsLabel = new Label(composite, SWT.NONE);
    detailsLabel.setText("");
        
    getSite().getPage().addSelectionListener(ViewA.ID, this);
    getSite().getPage().addSelectionListener(ViewB.ID, this);
}
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if (part instanceof ViewA || part instanceof ViewB){
        showDetailsOfEntries(
            selection instanceof IStructuredSelection structuredSelection ?
            structuredSelection.toList() : Collections.emptyList() );
    }
}
private void showDetailsOfEntries( List<?> entries) {
    String details = entries.stream().map(Object::toString).collect(Collectors.joining(", "));
    detailsLabel.setText(details);
    composite.layout(true);
}

I can switch back and forth between “A” and “B”, and the “Details” view show the details of the selected entries of “A” or “B”.

I tried to migrate this to rcp e4:

ViewA und ViewB:

@Inject
private ESelectionService selectionService

@PostConstruct
public void createPartControl(Composite parent) {
    ...
    viewer.addSelectionChangedListener(event -> {
        selectionService.setSelection(event.getSelection());
});

DetailsView:

@Inject
private ESelectionService selectionService

@PostConstruct
public void createPartControl(Composite parent) {
    ...
    selectionService.addSelectionListener(ViewA.ID, this);
    selectionService.addSelectionListener(ViewB.ID, this);
}
public void selectionChanged(MPart part, Object selection) {
    if (part.getElementId().equals(ViewA.ID) || part.getElementId().equals(ViewB.ID)) {
        ...
    }
}

But now the behavior is different. Switching between the views “A” and “B” don’t change the selection and so there is no update in the “Details” view. The “selectionChanged” method in “Details” view is now only be called if there is a new selection in view “A” or “B” and not when switching between view “A” and “B” as it was in rcp3.

How can I achieve the old behavior?

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật