Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2009 IBM Corporation 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: IBM Corporation - initial API and implementation /
package org.eclipse.team.internal.ccvs.ui.repo;
import  org.eclipse.swt.dnd.*;
import  org.eclipse.swt.widgets.Display;
public class CopyRepositoryNameAction extends CVSAction {
	public boolean isEnabled() {
		return getSelectedRepositories().length > 0;
	}
	public void execute(IAction action) {
		if (locations.length == 0)
			return;
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < locations.lengthi++) {
			buffer.append(locations[i].getLocation(true));
			if (i < locations.length - 1) buffer.append("\n"); //$NON-NLS-1$
		}
		copyToClipbard(Display.getDefault(), buffer.toString());
	}
		ArrayList repositories = null;
		if (!selection.isEmpty()) {
			repositories = new ArrayList();
			Iterator elements = selection.iterator();
			while (elements.hasNext()) {
				Object next = getAdapter(elements.next(), ICVSRepositoryLocation.class);
				if (next instanceof ICVSRepositoryLocation) {
					repositories.add(next);
					continue;
				}
			}
		}
		if (repositories != null && !repositories.isEmpty()) {
			ICVSRepositoryLocation[] result = new ICVSRepositoryLocation[repositories.size()];
			repositories.toArray(result);
			return result;
		}
		return new ICVSRepositoryLocation[0];
	}
	private void copyToClipbard(Display displayString str) {
		Clipboard clipboard = new Clipboard(display);
		clipboard.setContents(new String[] { str },	new Transfer[] { TextTransfer.getInstance()});
		clipboard.dispose();
	}
New to GrepCode? Check out our FAQ X