/******************************************************************************* * Copyright (c) 2014, 2015 Red Hat Inc. * 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: * Mickael Istria (Red Hat Inc.) - initial API and implementation ******************************************************************************/ package org.eclipse.ui.internal.navigator.resources.actions; import org.eclipse.core.resources.IProject; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE.SharedImages; import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages; import org.eclipse.ui.navigator.CommonViewer; /** * @since 3.3 * */ public class SelectProjectForFolderAction extends Action { private IProject project; private CommonViewer viewer; /** * @param project * @param viewer */ public SelectProjectForFolderAction(IProject project, CommonViewer viewer) { super(NLS.bind(WorkbenchNavigatorMessages.SelectProjectForFolderAction_SelectProject, project.getName())); this.project = project; this.viewer = viewer; setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(SharedImages.IMG_OBJ_PROJECT)); } @Override public void run() { viewer.setSelection(new StructuredSelection( new Object[] { this.project } )); } }