blob: 0812a00d9591e1a57c180c59a266bb586d4547f2 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pierre Allard,
* Regent L'Archeveque,
* Olivier L. Larouche - initial API and implementation
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.common.emf.ui.parts;
import org.eclipse.apogy.common.ui.ApogyCommonUIRCPConstants;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
import org.eclipse.e4.ui.model.application.ui.menu.impl.HandledToolItemImpl;
@SuppressWarnings("restriction")
public interface ToolBarMenuPart {
/**
* Is notified when a menu item is selected.
*
* @param parameterID ID specified in the handledToolItem's parameters.
* @param selected value of selected of the ToolItem.
*/
void toolItemSelectedChanged(String parameterID, boolean selected);
/**
* Specifies if a toolItemSelectedChanged can be called.
*/
boolean canExecute();
/**
* Initializes the part's content if needed. This can be used for a
* persistedState.
*
* @param toolBar The toolBar of the part.
*/
default void init(MToolBar toolBar) {
for (MUIElement toolbarElement : toolBar.getChildren()) {
if (toolbarElement instanceof HandledToolItemImpl && ((HandledToolItemImpl) toolbarElement).getCommand()
.getElementId().equals(ApogyCommonUIRCPConstants.COMMAND__OPEN_TOOL_BAR_MENU__ID)) {
((HandledToolItemImpl) toolbarElement).setSelected(false);
}
}
};
}