| // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, com.instantiations.assist.eclipse.analysis.deserializeabilitySecurity, com.instantiations.assist.eclipse.analysis.disallowReturnMutable, com.instantiations.assist.eclipse.analysis.enforceCloneableUsageSecurity |
| /******************************************************************************* |
| * Copyright (c) 2010, 2012 Ericsson AB 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 |
| * |
| * Description: |
| * |
| * This class implements the context-sensitive command used |
| * to open the editor on the selected element |
| * |
| * Contributors: |
| * Sebastien Dubois - Created for Mylyn Review R4E project |
| * |
| ******************************************************************************/ |
| package org.eclipse.mylyn.reviews.r4e.ui.internal.commands.handlers; |
| |
| import java.util.List; |
| |
| import org.eclipse.core.commands.AbstractHandler; |
| import org.eclipse.core.commands.ExecutionEvent; |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.core.runtime.IStatus; |
| import org.eclipse.core.runtime.Status; |
| import org.eclipse.jface.viewers.StructuredSelection; |
| import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.EditorProxy; |
| import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement; |
| import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController; |
| import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils; |
| import org.eclipse.ui.progress.UIJob; |
| |
| /** |
| * @author Sebastien Dubois |
| * @version $Revision: 1.0 $ |
| */ |
| public class OpenEditorHandler extends AbstractHandler { |
| |
| // ------------------------------------------------------------------------ |
| // Constants |
| // ------------------------------------------------------------------------ |
| |
| /** |
| * Field COMMAND_MESSAGE. (value is ""Opening Editor..."") |
| */ |
| private static final String COMMAND_MESSAGE = "Opening Editor..."; |
| |
| // ------------------------------------------------------------------------ |
| // Methods |
| // ------------------------------------------------------------------------ |
| |
| /** |
| * Method execute. |
| * |
| * @param aEvent |
| * ExecutionEvent |
| * @return Object |
| * @see org.eclipse.core.commands.IHandler#execute(ExecutionEvent) |
| */ |
| public Object execute(final ExecutionEvent aEvent) { |
| |
| final List<IR4EUIModelElement> selectedElements = UIUtils.getCommandUIElements(); |
| |
| final UIJob job = new UIJob(COMMAND_MESSAGE) { |
| @Override |
| public IStatus runInUIThread(IProgressMonitor monitor) { |
| monitor.beginTask(COMMAND_MESSAGE, 1); |
| |
| if (!selectedElements.isEmpty()) { |
| EditorProxy.openEditor(R4EUIModelController.getNavigatorView().getSite().getPage(), |
| new StructuredSelection(selectedElements), true); |
| } |
| monitor.worked(1); |
| monitor.done(); |
| return Status.OK_STATUS; |
| } |
| }; |
| job.setUser(true); |
| job.schedule(); |
| return null; |
| } |
| } |