本文整理匯總了Java中org.eclipse.jface.viewers.ITreeContentProvider.getElements方法的典型用法代碼示例。如果您正苦於以下問題:Java ITreeContentProvider.getElements方法的具體用法?Java ITreeContentProvider.getElements怎麽用?Java ITreeContentProvider.getElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.viewers.ITreeContentProvider
的用法示例。
在下文中一共展示了ITreeContentProvider.getElements方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getElements
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
/**
* @see org.eclipse.ui.navigator.SaveablesProvider#getElements(org.eclipse.ui.Saveable)
*/
@Override
public Object[] getElements(Saveable pSaveable) {
if (pSaveable == null) {
return new Object[] {};
}
CommonViewer viewer = ProjectRegistry.ViewerRegistry.getViewer();
ITreeContentProvider contentProvider = (ITreeContentProvider) viewer.getContentProvider();
Object viewerInput = viewer.getInput();
if (contentProvider == null) {
return null;
}
return contentProvider.getElements(viewerInput);
}
示例2: selectAll
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
/**
* Selects or deselects all methods.
*
* @param state
* @throws JavaModelException
*/
private void selectAll(boolean state) {
CheckboxTreeViewer checkboxTreeViewer = getGroup().getCheckboxTreeViewer();
ITreeContentProvider contentProvider = (ITreeContentProvider) checkboxTreeViewer.getContentProvider();
Object[] objects = contentProvider.getElements(checkboxTreeViewer.getInput());
for (Object object : objects) {
checkboxTreeViewer.setChecked(object, state);
}
for (IMethod method : getBaseClassMethods()) {
if (viewerFilterMethods.select(null, method.getParent(), method)) {
if (state) {
checkedMethods.add(method);
} else {
checkedMethods.remove(method);
}
}
}
}
示例3: getElements
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
public Object[] getElements(Object inputElement)
{
List<ITreeContentProvider> providers = this.getProcessors();
List<Object> result = new ArrayList<Object>();
for (ITreeContentProvider provider : providers)
{
Object[] items = provider.getElements(inputElement);
result.addAll(Arrays.asList(items));
}
return result.toArray();
}
示例4: applyExpandHeuristic
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
/**
* A heuristic for determining how much information to show in this view. If
* nodes of the tree have an excessively large number of children then it
* may not always be ideal to display all the children by default. This
* method attempts to display a reasonable amount of information to the
* user.
*
* @param treeViewer
*/
protected void applyExpandHeuristic(TreeViewer treeViewer) {
ITreeContentProvider cp = (ITreeContentProvider) treeViewer.getContentProvider();
Object[] rootChildren = cp.getElements(null);
if (rootChildren.length == 0) return;
Object root = cp.getParent(rootChildren[0]);
FindFilter filter = new FindFilter();
Object children[] = filter.filter(treeViewer, root, rootChildren);
if(children.length == 1) {
treeViewer.expandAll();
return;
}
int totalChildren = 0;
for(int i=0; i<25 && i<children.length; i++) {
totalChildren += filter.filter(treeViewer, children[i], cp.getChildren(children[i])).length;
}
if(totalChildren > 25) {
treeViewer.collapseAll();
treeViewer.expandToLevel(root, 1);
} else {
treeViewer.expandAll();
}
}
示例5: applyExpandHeuristic
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
protected void applyExpandHeuristic(String key, String stringToMatch) {
ITreeContentProvider cp = (ITreeContentProvider) treeViewer.getContentProvider();
final Object[] rootChildren = cp.getElements(null);
if (rootChildren != null && rootChildren.length != 0) {
if (rootChildren.length <= 25 && !CommonUtils.isNullOrEmpty(stringToMatch)) {
for(Object object : rootChildren) {
treeViewer.expandToLevel(object, AbstractTreeViewer.ALL_LEVELS);
}
} else {
treeViewer.collapseAll();
}
}
}
示例6: testGetElements
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
/**
* Test if the method getElements() returns a correct result.
*/
@Test
public void testGetElements() {
ITreeContentProvider packagesTreeContentProvider = new PackagesTreeContentProvider();
IPackageFragment javaPackage1 = mock(IPackageFragment.class);
IPackageFragment javaPackage2 = mock(IPackageFragment.class);
IPackageFragment[] rootPackages = { javaPackage1, javaPackage2 };
Object[] result = packagesTreeContentProvider.getElements(rootPackages);
assertThat("returned root packages", (IPackageFragment[]) result, is(rootPackages));
}
示例7: generateNewLabel
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
/**
* create new unique text for a "label" attribute, if present, by looking at all existing.
* @param displayName
* @return
*/
protected String generateNewLabel(FacesDefinition def) {
String label = "Label"; // $NLX-AbstractTreeNodePanel.Label-1$
String displayName = getLinkDisplayName(def);
if (null == displayName)
return label;
Object input = ruleViewer.getInput();
ITreeContentProvider cp = (ITreeContentProvider)ruleViewer.getContentProvider();
Object[] children = cp.getElements(input);
Stack<Object> stack = new Stack<Object>(); // for non-recursive tree traversal
stack.push(input);
Set<String> set = new HashSet<String>(); // collects current names
while (!stack.isEmpty()) {
if (null != children) {
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof Element) {
String l = XPagesDOMUtil.getAttribute((Element)children[i], EXT_LIB_ATTR_LABEL);
if (StringUtil.isNotEmpty(l))
set.add(l);
}
stack.push(children[i]);
}
}
children = cp.getChildren(stack.pop());
}
while (!stack.isEmpty());
String prefix = displayName;
String[] splits = displayName.split(" "); //$NON-NLS-1$
if (null != splits && splits.length > 0) {
prefix = splits[0];
for (int i = 1; i < 100; i++) {
String thistry = prefix + " " + String.valueOf(i); //$NON-NLS-1$
if (!set.contains(thistry)) {
label = thistry;
break;
}
}
}
return label;
}
示例8: generateNewLabel
import org.eclipse.jface.viewers.ITreeContentProvider; //導入方法依賴的package包/類
/**
* create new unique text for a "label" attribute, if present, by looking at all existing.
* @param displayName
* @return
*/
protected String generateNewLabel(FacesDefinition def) {
if(StringUtil.equals(def.getTagName(), IExtLibTagNames.EXT_LIB_TAG_DOMINO_VIEW_LIST)){
return null; //for the dominoViewListTreeNode tag we do not want to set the label!
}
String label = "Label"; // $NLX-AbstractTreeNodePanel.Label-1$
String displayName = getLinkDisplayName(def, false);
if (null == displayName)
return label;
Object input = _linkViewer.getInput();
ITreeContentProvider cp = (ITreeContentProvider)_linkViewer.getContentProvider();
Object[] children = cp.getElements(input);
Stack<Object> stack = new Stack<Object>(); // for non-recursive tree traversal
stack.push(input);
Set<String> set = new HashSet<String>(); // collects current names
while (!stack.isEmpty()) {
if (null != children) {
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof Element) {
String l = XPagesDOMUtil.getAttribute((Element)children[i], EXT_LIB_ATTR_LABEL);
if (StringUtil.isNotEmpty(l))
set.add(l);
}
stack.push(children[i]);
}
}
children = cp.getChildren(stack.pop());
}
while (!stack.isEmpty());
String prefix = displayName;
String[] splits = displayName.split(" "); //$NON-NLS-1$
if (null != splits && splits.length > 0) {
prefix = splits[0];
for (int i = 1; i < 100; i++) {
String thistry = prefix + " " + String.valueOf(i); //$NON-NLS-1$
if (!set.contains(thistry)) {
label = thistry;
break;
}
}
}
return label;
}