1 /*******************************************************************************
2  * Copyright (c) 2002, 2005 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM - Initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.core.tools;
15 
16 import org.eclipse.jface.text.ITextSelection;
17 import org.eclipse.jface.viewers.ISelectionProvider;
18 
19 /**
20  * A concrete implementation for <code>AbstractCopySelectionAction</code> that
21  * supports text selections.
22  *
23  * @see org.eclipse.jface.text.ITextSelection
24  */
25 public class CopyTextSelectionAction extends AbstractCopySelectionAction {
26 
27 	/**
28 	 * @see AbstractCopySelectionAction#AbstractCopySelectionAction
29 	 * (ISelectionProvider)
30 	 */
CopyTextSelectionAction(ISelectionProvider selectionProvider)31 	public CopyTextSelectionAction(ISelectionProvider selectionProvider) {
32 		super(selectionProvider);
33 	}
34 
35 	/**
36 	 * Returns the current text selection.
37 	 *
38 	 * @return a string containing the currently selected text
39 	 * @see org.eclipse.core.tools.AbstractCopySelectionAction#getContents()
40 	 */
41 	@Override
getContents()42 	protected String getContents() {
43 		return ((ITextSelection) selectionProvider.getSelection()).getText();
44 	}
45 
46 }
47