/*******************************************************************************
* Copyright (c) 2013 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.cdt.internal.ui.util.SelectionUtil;
/**
* Handler for {@link org.eclipse.cdt.internal.ui.actions.CreateParserLogAction}
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class CreateParserLogHandler extends AbstractHandler {
private final CreateParserLogAction createParserLogAction = new CreateParserLogAction();
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IWorkbenchPart part = HandlerUtil.getActivePart(event);
createParserLogAction.setActivePart(null, part);
createParserLogAction.selectionChanged(null, selection);
createParserLogAction.run(null);
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
*/
@Override
public void setEnabled(Object evaluationContext) {
ISelection selection = SelectionUtil.getActiveSelection();
setBaseEnabled(createParserLogAction.isEnabledFor(selection));
}
}