01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.tests.views.properties.tabbed.text;
11:
12: import java.util.ArrayList;
13: import java.util.List;
14: import java.util.StringTokenizer;
15:
16: import org.eclipse.jface.text.ITextSelection;
17: import org.eclipse.jface.viewers.ISelection;
18: import org.eclipse.ui.IWorkbenchPart;
19: import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
20: import org.eclipse.ui.views.properties.tabbed.ITabDescriptorProvider;
21:
22: /**
23: * A tab descriptor for the text test view.
24: *
25: * @author Anthony Hunter
26: */
27: public class TextTestsTabDescriptorProvider implements
28: ITabDescriptorProvider {
29:
30: public ITabDescriptor[] getTabDescriptors(IWorkbenchPart part,
31: ISelection selection) {
32: if (selection instanceof ITextSelection) {
33: ITextSelection textSelection = (ITextSelection) selection;
34: if (textSelection.getLength() != 0) {
35: List result = new ArrayList();
36: StringTokenizer tokenizer = new StringTokenizer(
37: textSelection.getText());
38: while (tokenizer.hasMoreTokens()) {
39: result.add(new TextTestsTabDescriptor(tokenizer
40: .nextToken()));
41: }
42: return (ITabDescriptor[]) result
43: .toArray(new ITabDescriptor[result.size()]);
44: }
45: }
46: return new ITabDescriptor[0];
47: }
48:
49: }
|