blob: 528fe7c62b97bdf2b27171a68c7004688f5016cc (
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
|
/*******************************************************************************
* Copyright (c) 2011, 2015 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.adapters;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.FsClipboard;
import org.eclipse.ui.IActionFilter;
/**
* This action filter wraps an IFSTreeNode and test its attribute of "cache.state".
* It serves as the expression filter of decorations of Target Explorer.
*/
public class NodeStateFilter implements IActionFilter {
private IFSTreeNode node;
/**
* Constructor.
*
* @param node
* The wrapped tree node. Must not be <code>null</code>.
*/
public NodeStateFilter(IFSTreeNode node) {
Assert.isNotNull(node);
this.node = node;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String)
*/
@Override
public boolean testAttribute(Object target, String name, String value) {
if (name.equals("cache.state") && node.isFile()) { //$NON-NLS-1$
if(UIPlugin.isAutoSaving())
return false;
CacheState state = node.getCacheState();
if (value == null)
value = CacheState.consistent.name();
return value.equals(state.name());
}
else if (name.equals("edit.cut")) { //$NON-NLS-1$
FsClipboard cb = UIPlugin.getClipboard();
if (!cb.isEmpty()) {
if (cb.isCutOp()) {
List<IFSTreeNode> files = cb.getFiles();
for (IFSTreeNode file : files) {
if (node == file) return true;
}
}
}
}
else if (name.equals("hidden")) { //$NON-NLS-1$
if (value == null) value = "true"; //$NON-NLS-1$
boolean result = false;
if (!node.isRootDirectory()) {
if (node.isWindowsNode()) {
result = node.isHidden();
}
else {
result = node.getName().startsWith("."); //$NON-NLS-1$
}
}
return Boolean.toString(result).equals(value);
}
return false;
}
}
|