다중화 컴포넌트 구현

멀티플렉서에서 사용하려면 사이트 인터페이스는 대체 기본 구현에 org.eclipse.ui.part.SiteMultiplexerInitializer 범위를 등록해야 합니다. 이는 사이트 범위로 확장되므로 멀티플렉서에서 사용될 경우 보다 특정한 멀티플렉서 버전이 기본 버전보다 우선권을 갖습니다.

다중화 컴포넌트는 대부분 다음과 같은 패턴을 사용합니다.
  1. INestedComponent 라이프 사이클 인터페이스 구현,
  2. 생성자에서 IMultiplexer를 사용하고 이를 사용하여 공유 버전의 인터페이스에 액세스,
  3. 부분 상태 저장,
  4. 하위의 상태 변경 청취 및 저장된 상태를 적절하게 갱신,
  5. 컴포넌트가 활성화될 때마다 저장된 상태를 멀티플렉서의 공유 인터페이스에 전달해야 함,
  6. 컴포넌트가 활성인 동안 상태 변경사항을 직업 공유 인터페이스에 전달해야 함.
다음 예제에서는 Workbench에서 ChildSelectionHandler를 사용하여 ISelectionHandler 인터페이스를 다중화하는 데 사용된 코드를 보여 줍니다.
/**
 * Multiplexed version of the ISelectionHandler interface
 *
 * @since 3.1
 */
public class ChildSelectionHandler implements ISelectionHandler, INestedComponent {

    private ISelectionHandler parent;
    private ISelection selection;
    private boolean isActive = false;
    private IMultiplexer multiplexer;

    public ChildSelectionHandler(IMultiplexer mplex) throws DependencyException {
        this.multiplexer = mplex;        
        // Get access to the shared ISelectionHandler being multiplexed (we should        
        // only modify it when we're the active child)        
        this.parent = (ISelectionHandler)
            mplex.getSharedComponents().getComponent(ISelectionHandler.class);        
                
        // Set the initial state (the part's initial selection will be null        
        // until it explicitly sets it).        
    }        

    public IMultiplexer getMultiplexer() {        
        // Return the multiplexer we were created with        
        return multiplexer;        
    }

    public void activate() {        
        // Forward our stored selection to the shared interface        
        parent.setSelection(selection);        
        isActive = true;        
    }        
            
    public void deactivate() {        
        isActive = false;        
    }        

    public void setSelection(ISelection newSelection) {        
        // Remember the child's new selection        
        selection = newSelection;        
        if (isActive) {        
             // If we're active, forward the selection directly to the
             // shared interface        
             parent.setSelection(newSelection);        
        }        
    }        
}        
다음은 ChildSelectionHandler에 연관된 확장점 마크업입니다.
<extension point="org.eclipse.core.component.types">        
    <component        
            implementation="org.eclipse.ui.internal.part.services.ChildSelectionHandler"        
            interface="org.eclipse.ui.part.services.ISelectionHandler"        
            singleton="false"        
            initializer="org.eclipse.ui.part.SiteMultiplexerInitializer"/>        
   </extension>
TestCompositeView의 스크린 샷