📄 flowexportwizardselectionmanager.java
字号:
*/
public Object[] getElements(Object inputElement) {
/*return flowTree.getUndelyingTreeChildren();
*/
return flowTree.branches.values().toArray();
}
/**
* @see ITreeContentProvider#getParent(Object)
*/
public Object getParent(Object element) {
/*IJavaElement parent = ((IJavaElement)element).getParent();
return parent;*/
FlowCheckTree elem = (FlowCheckTree) element;
return elem.parent;
}
/**
* @see ITreeContentProvider#hasChildren(Object)
*/
public boolean hasChildren(Object element) {
/*if (element instanceof IPackageFragment)
return false;
return (getChildren(element).length > 0);*/
FlowCheckTree elem = (FlowCheckTree) element;
return elem.branches != null && (!elem.branches.isEmpty());
}
/*
* @see IContentProvider#dispose()
*/
public void dispose() {
}
/*
* @see IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(
Viewer viewer,
Object oldInput,
Object newInput) {
}
}
/**
* @author alex
*
* TODO
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
private class ListContentProvider implements ITreeContentProvider {
private final Object[] NO_CHILDREN = new Object[0];
/*
* @see ITreeContentProvider#getChildren(Object)
*/
public Object[] getChildren(Object parentElement) {
return NO_CHILDREN;
}
/*
* @see ITreeContentProvider#getParent(Object)
*/
public Object getParent(Object element) {
/*if (element instanceof IPackageFragment)
return ((IPackageFragment)element).getParent();
return null;*/
FlowCheckItem elem = (FlowCheckItem) element;
return elem.parent;
}
/**
* @see ITreeContentProvider#hasChildren(Object)
*/
public boolean hasChildren(Object element) {
return false;
}
/**
* Returns all flow flowFile elements as an IResource array.
* @see IStructuredContentProvider#getElements(Object)
*/
public Object[] getElements(Object inputElement) {
FlowCheckTree elem = (FlowCheckTree) inputElement;
/*return elem.getUndelyingListChildren();*/
return elem.items == null ? NO_CHILDREN : elem.items.toArray();
}
/*
* @see IContentProvider#dispose()
*/
public void dispose() {
}
/*
* @see IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(
Viewer viewer,
Object oldInput,
Object newInput) {
}
}
/**
*
* @author alex
*
* TODO
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
class FlowCheckTree {
Map branches;
List items;
Object underlyingObject;
boolean isChecked;
FlowCheckTree parent;
/**
*
* TODO
* @param parent
* @param underlyingObject
*/
FlowCheckTree(FlowCheckTree parent, Object underlyingObject) {
this.parent = parent;
this.underlyingObject = underlyingObject;
}
/**
*
* TODO
* @return
*/
IPath getPath() {
IPath path =
new Path(((IJavaElement) underlyingObject).getElementName());
FlowCheckTree parentTree = parent;
while (parentTree.underlyingObject != null) {
path =
new Path(
((IJavaElement) parentTree.underlyingObject)
.getElementName())
.append(
path);
parentTree = parentTree.parent;
}
return path;
}
/**
*
* TODO
* @param filePath
*/
void store(IPath filePath, List underlyingObjectPath) {
if (filePath.segmentCount() == 1)
store(filePath.segment(0), underlyingObjectPath.get(0));
else {
String firstSeg = filePath.segment(0);
if (branches == null)
branches = new TreeMap();
FlowCheckTree subTree = (FlowCheckTree) branches.get(firstSeg);
if (subTree == null) {
subTree =
new FlowCheckTree(this, underlyingObjectPath.get(0));
branches.put(firstSeg, subTree);
}
underlyingObjectPath.remove(0);
subTree.store(
filePath.removeFirstSegments(1),
underlyingObjectPath);
}
}
/**
*
* TODO
* @param path
* @return
*/
FlowCheckTree getBranch(IPath path) {
String firstSeg = path.segment(0);
FlowCheckTree child = (FlowCheckTree) branches.get(firstSeg);
if (path.segmentCount() == 1)
return child;
else
return child.getBranch(path.removeFirstSegments(1));
}
/**
*
* TODO
* @param fileName
*/
void store(String fileName, Object underlyingObject) {
if (items == null)
items = new ArrayList();
items.add(new FlowCheckItem(fileName, this, underlyingObject));
}
/**
* Returns the underlying tree objects of the JDT packages
* @return the underlying tree objects of the JDT packages
*/
/*Object[] getUndelyingTreeChildren() {
List result = new ArrayList();
if (branches != null)
for (Iterator iter = branches.values().iterator(); iter.hasNext();) {
FlowCheckTree subTree = (FlowCheckTree)iter.next();
result.add(subTree.underlyingObject);
}
return result.toArray();
}*/
/**
* Returns the underlying list objects of the JDT packages
* @return the underlying list objects of the JDT packages
*/
/*Object[] getUndelyingListChildren() {
List result = new ArrayList();
if (items != null)
for (Iterator iter = items.iterator(); iter.hasNext();) {
FlowCheckItem item = (FlowCheckItem)iter.next();
result.add(item.underlyingObject);
}
return result.toArray();
}*/
/**
*
* TODO
* @param path
* @param checked
*/
void setChecked(IPath path, boolean checked) {
if (path == null || path.segmentCount() == 0) {
isChecked = checked;
//treeViewer.setChecked(underlyingObject, checked);
treeViewer.setChecked(this, checked);
if (branches != null)
for (Iterator iter = branches.values().iterator();
iter.hasNext();
) {
FlowCheckTree subTree = (FlowCheckTree) iter.next();
subTree.setChecked(null, checked);
}
if (items != null)
for (Iterator iter = items.iterator(); iter.hasNext();) {
FlowCheckItem item = (FlowCheckItem) iter.next();
item.setChecked(checked);
}
} else {
String firstSeg = path.segment(0);
FlowCheckTree subTree = null;
if (branches != null)
subTree = (FlowCheckTree) branches.get(firstSeg);
if (subTree == null) {
// it's a flow item
FlowCheckItem item = getItem(firstSeg);
if (item != null)
item.setChecked(checked);
} else
subTree.setChecked(path.removeFirstSegments(1), checked);
}
}
/**
* Returns the item that's name equals the given name.
* @param name
* @return the item that's name equals the given name.
*/
private FlowCheckItem getItem(String name) {
for (Iterator iter = items.iterator(); iter.hasNext();) {
FlowCheckItem item = (FlowCheckItem) iter.next();
if (item.name.equals(name))
return item;
}
return null;
}
/**
*
* Returns the selected flow filesin form of a map.
*
* key= parents path, value= underlying IFile
* @return the selected flow filesin form of a map.
*/
public Map getCheckedFlowResources() {
Map result = new HashMap();
getCheckedFlowResources(result);
return result;
}
/**
*
* TODO
* @param flowResources
*/
private void getCheckedFlowResources(Map flowResources) {
if (items != null)
for (Iterator iter = items.iterator(); iter.hasNext();) {
FlowCheckItem item = (FlowCheckItem) iter.next();
if (item.isChecked)
flowResources.put(
item.getPath(),
item.underlyingObject);
}
if (branches != null)
for (Iterator iter = branches.values().iterator();
iter.hasNext();
) {
FlowCheckTree subTree = (FlowCheckTree) iter.next();
subTree.getCheckedFlowResources(flowResources);
}
}
public String toString() {
return ((IJavaElement) underlyingObject).getElementName();
}
}
/**
*
* @author alex
*
* TODO
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
class FlowCheckItem {
String name;
Object underlyingObject;
boolean isChecked;
FlowCheckTree parent;
FlowCheckItem(
String name,
FlowCheckTree parent,
Object underlyingObject) {
this.name = name;
this.parent = parent;
this.underlyingObject = underlyingObject;
}
void setChecked(boolean checked) {
isChecked = checked;
// listViewer.setChecked(underlyingObject, checked);
listViewer.setChecked(this, checked);
}
IPath getPath() {
return parent.getPath().append(name);
}
public String toString() {
return name;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -