/*******************************************************************************
 * File: RemoveSelectionOppositePartHandler.java
 * 
 * Date: 27 авг. 2014 г.
 * Author: Mikhail Niedre
 * 
 * Copyright (c) 2014 Original authors and others.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * <a href="http://www.eclipse.org/legal/epl-v10.html">epl-v1.0</a>
 *
 * Contributors:
 * Mikhail Niedre - initial API and implementation
 *******************************************************************************/
package cane.brothers.e4.commander.handlers;

import javax.inject.Inject;

import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;

import cane.brothers.e4.commander.PathEvents;
import cane.brothers.e4.commander.utils.PartUtils;

/**
 * remove selection on non active part by event.
 */
public class RemoveSelectionPartHandler {

    @Inject
    private EPartService partService;

    @Inject
    @Optional
    @Execute
    public void removeSelection(
	    @UIEventTopic(PathEvents.TAB_REMOVE_SELECTION) MPart activePart) {

	if (activePart != null && partService != null) {

	    // pass throw all parts
	    for (MPart p : partService.getParts()) {
		if (p != null && !p.equals(activePart)) {

		    PartUtils.clearSelection(p);
		    System.out.println("remove selection from non active tab");
		}
	    }
	}
    }

}

@@ -1245,24 +1245,27 @@
 ervice;%0A%0A   
+ //
  @Inject%0A   
@@ -1269,17 +1269,250 @@
     
-@Optional
+// public void clearOtherSelection(%0A    // @Optional @Named(IServiceConstants.ACTIVE_SELECTION) PathFixture%0A    // selectedFixture) %7B%0A    // if (selectedFixture != null) %7B%0A    // System.out.println(%22selection%22);%0A    // %7D%0A    // %7D%0A%0A    @Inject
 %0A   
@@ -1559,16 +1559,26 @@
 n(%0A%09    
+@Optional 
 @UIEvent

move @optional