blob: 922addd39d1d9589b77ccb3ee555bb85896baee4 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*******************************************************************************
* Copyright (c) 2011 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.internal.operations;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.tcf.te.tcf.filesystem.model.FSModel;
import org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode;
/**
* The clip board to which copy or cut files/folders.
*/
public class FSClipboard {
// The constants to define the current operation type of the clip board.
public static final int NONE = -1;
public static final int CUT = 0;
public static final int COPY = 1;
// The operation type, CUT, COPY or NONE.
private int operation;
// The currently selected files/folders.
private List<URL> files;
/**
* Create a clip board instance.
*/
public FSClipboard() {
operation = NONE;
}
/**
* If the clip board is empty.
*
* @return true if the operation is NONE and no files are selected.
*/
public boolean isEmpty() {
return operation == NONE && (files == null || files.isEmpty());
}
/**
* Return the current operation type.
*
* @return The operation of the current clip board content.
*/
public int getOperation() {
return operation;
}
/**
* Get the currently selected files/folders to operated.
*
* @return The file/folder list using their location URLs.
*/
public List<URL> getFiles() {
return files;
}
/**
* Cut the specified files/folders to the clip board.
*
* @param files The file/folder nodes.
*/
public void cutFiles(List<URL> files) {
operation = CUT;
this.files = files;
}
/**
* Copy the specified files/folders to the clip board.
*
* @param files The file/folder nodes.
*/
public void copyFiles(List<URL> files) {
operation = COPY;
this.files = files;
}
/**
* Clear the clip board.
*/
public void clear() {
operation = NONE;
this.files = null;
}
public List<FSTreeNode> getTreeNodes() {
List<FSTreeNode> nodes = new ArrayList<FSTreeNode>();
for (URL file : files) {
FSTreeNode node = FSModel.getInstance().getTreeNode(file);
nodes.add(node);
}
return nodes;
}
}
|