blob: 9f8b01d2225cfcde3cc458f5d6f97351ec5bb8cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpMove;
import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSFolderSelectionDialog;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* The handler that moves the selected files or folders to a destination folder.
*/
public class MoveFilesHandler extends AbstractHandler {
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShellChecked(event);
FSFolderSelectionDialog dialog = new FSFolderSelectionDialog(shell);
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
List<FSTreeNode> nodes = selection.toList();
IPeerNode peer = nodes.get(0).peerNode;
dialog.setInput(peer);
dialog.setMovedNodes(nodes);
if (dialog.open() == Window.OK) {
Object obj = dialog.getFirstResult();
Assert.isTrue(obj instanceof FSTreeNode);
FSTreeNode dest = (FSTreeNode) obj;
IOpExecutor executor = new UiExecutor();
executor.execute(new OpMove(nodes, dest, new MoveCopyCallback()));
}
return null;
}
}
|