当前位置: 首页>>代码示例>>Java>>正文


Java Tree.getItem方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.Tree.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.getItem方法的具体用法?Java Tree.getItem怎么用?Java Tree.getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.Tree的用法示例。


在下文中一共展示了Tree.getItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldCreateToolTip

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
@Override
protected boolean shouldCreateToolTip(final Event e) {
	this.lastDescriptor = null;
	if (e.widget instanceof Tree) {
		final Tree tree = (Tree) e.widget;
		final TreeItem item = tree.getItem(new Point(e.x, e.y));

		if (null != item && item.getData() instanceof ResultNode) {
			final ResultNode node = (ResultNode) item.getData();
			if (node.getElement() instanceof TestCase) {
				final URI uri = ((TestCase) node.getElement()).getURI();
				if (null != uri) {
					final StyledTextDescriptor descriptor = getDescriptor(uri);
					if (null != descriptor) {
						this.lastDescriptor = descriptor;
					}
				}
			}
		}
	}

	return null != this.lastDescriptor;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:TestResultsView.java

示例2: findObjectAtExcluding

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * @see org.eclipse.gef.EditPartViewer#findObjectAtExcluding(Point, Collection, EditPartViewer.Conditional)
 */
@Override
public EditPart findObjectAtExcluding(Point pt, Collection exclude, Conditional condition) {
  if (getControl() == null)
    return null;

  final Tree tree = getTreeControl();
  Rectangle area = tree.getClientArea();
  if (pt.x < area.x || pt.y < area.y || pt.x >= area.x + area.width || pt.y >= area.y + area.height)
    return null;

  EditPart result = null;
  TreeItem tie = tree.getItem(new org.eclipse.swt.graphics.Point(pt.x, pt.y));

  if (tie != null) {
    result = (EditPart) tie.getData();
  } else if (tree.getData() instanceof EditPart) {
    result = (EditPart) tree.getData();
  }
  while (result != null) {
    if ((condition == null || condition.evaluate(result)) && !exclude.contains(result))
      return result;
    result = result.getParent();
  }
  return null;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:29,代码来源:PaletteTreeViewer.java

示例3: handleTreeViewerMouseUp

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * Handles mouse up action for the tree viewer
 * 
 * @param tree
 *            current tree
 * @param e
 *            mouse event
 */
private void handleTreeViewerMouseUp(final Tree tree, MouseEvent e) {
	// Ensure a selection was made, the first mouse button was
	// used and the event happened in the tree
	if ((tree.getSelectionCount() < 1) || (e.button != 1) || !tree.equals(e.getSource())) {
		return;
	}
	// Selection is made in the selection changed listener
	Object object = tree.getItem(new Point(e.x, e.y));
	TreeItem selection = tree.getSelection()[0];
	if (selection.equals(object)) {
		gotoSelectedElement();
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:22,代码来源:AbstractInformationControl.java

示例4: locateEntryValue

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
private Object[] locateEntryValue(int x, int y) {
    final MultiDiffInput input = (MultiDiffInput)viewer.getInput();
    if(input == null) {
        return null;
    }

    final Tree tree = (Tree)viewer.getControl();
    final Point p = new Point(x, y);
    final TreeItem item = tree.getItem(p);
    if(item == null) {
        return null;
    }

    int columnIndex = -1;
    int numCols = tree.getColumnCount();
    for(int i = 0; i < numCols; ++i) {
        Rectangle rect = item.getBounds(i);
        if(rect.contains(p)) {
            columnIndex = i;
            break;
        }
    }
    
    if(columnIndex <= 0) {
        return null;
    }

    TreeNode en = input.entries.get(columnIndex - 1);
    TreeNodeLike vn = (TreeNodeLike)item.getData();

    EntryData ed = EntryData.of(en);
    vn = ed.valueTree().find(vn.path()).get();

    return new Object[]{en, vn};
}
 
开发者ID:insweat,项目名称:hssd,代码行数:36,代码来源:MultiDiffView.java

示例5: dropDetailBands

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * Check if the user is dragging a detail band to move it before or after another detail band. In this case it return
 * the command to do this operation, otherwise null
 * 
 * @return command to move the detail band or null if the user is not moving the band
 */
private JSSCompoundCommand dropDetailBands() {
	DropTargetEvent cEvent = getCurrentEvent();
	if (cEvent.detail != DND.DROP_MOVE)
		return null;
	if (cEvent.item == null || !(cEvent.item instanceof TreeItem))
		return null;
	
	//Get the list of element from the event or from the selection (as fallback)
	List<?> selectedItems = null;
	if (cEvent.data != null){
		if (cEvent.data instanceof List) {
			selectedItems = (List<?>) cEvent.data;
		} else {
			//I'm dragging something that it isn't a list, probably an element from the 
			//outline, so it isn't a drag band command
			return null;
		}
	} else {
		selectedItems = getViewer().getSelectedEditParts();
	}
	 
	List<MBand> movedBands = new ArrayList<MBand>();
	BandTypeEnum moveType = ReorderBandCommandBySibling.getMoveType(selectedItems, movedBands);
	if (moveType == null) return null;
	
	//Calculate the two element between the dragged element is moved
	Tree tree = ((TreeItem) cEvent.item).getParent();
	Point pt = tree.getDisplay().map(null, tree, cEvent.x, cEvent.y);
	TreeItem firstItem = tree.getItem(new Point(pt.x, pt.y-5));
	TreeItem secondItem = tree.getItem(new Point(pt.x, pt.y+5));

	if (firstItem == null || !(firstItem.getData() instanceof NotDragableContainerTreeEditPart))
		return null;
	if (secondItem == null || !(secondItem.getData() instanceof NotDragableContainerTreeEditPart))
		return null;
	Object model1 = ((NotDragableContainerTreeEditPart) firstItem.getData()).getModel();
	Object model2 = ((NotDragableContainerTreeEditPart) secondItem.getData()).getModel();
	MBand band1 = null;
	MBand band2 = null;
	if (model1 instanceof MBand){
		band1 = (MBand) model1;
	} 
	if (model2 instanceof MBand){
		band2 = (MBand) model2;
	}
	//One of the two element must be a band, otherwise the drag can't be done
	if (band1 == null || band2 == null) return null;
	JRBand targetNode = null;
	if (band1.getBandType().equals(moveType)) targetNode = band1.getValue();
	else if (!band2.getBandType().equals(moveType)) return null; //the destination bands are both different from the dragged band
	
	return ReorderBandCommandBySibling.moveBandsCommand(movedBands, targetNode, ((NotDragableContainerTreeEditPart) firstItem.getData()).getParent());
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:60,代码来源:JSSTemplateTransferDropTargetListener.java

示例6: reorderMapProvider

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
private boolean reorderMapProvider(final TVIMapProvider droppedMP) {

		final Tree mpTree = fMpViewer.getTree();
		final TVIMapProviderRoot rootItem = fDialogMPProfile.getRootItem();

		// remove drop item before it is inserted
		fMpViewer.remove(droppedMP);

		int itemIndex;

		if (fTargetTreeItem == null) {

			// a tree item is not hovered

			fMpViewer.add(rootItem, droppedMP);
			itemIndex = mpTree.getItemCount() - 1;

		} else {

			// get index of the target in the table
			itemIndex = mpTree.indexOf((TreeItem) fTargetTreeItem);
			if (itemIndex == -1) {
				return false;
			}

			// insert into the tree
			final int location = getCurrentLocation();
			if (location == LOCATION_BEFORE) {
				fMpViewer.insert(rootItem, droppedMP, itemIndex);
			} else if (location == LOCATION_AFTER) {
				fMpViewer.insert(rootItem, droppedMP, ++itemIndex);
			}
		}

		// reselect filter item
		fMpViewer.setSelection(new StructuredSelection(droppedMP));

		// set focus and selection
		final TreeItem droppedTreeItem = mpTree.getItem(itemIndex);

		mpTree.select(droppedTreeItem);
		mpTree.setFocus();

		fDialogMPProfile.updateLiveView();

		return true;
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:48,代码来源:ProfileDropAdapter.java


注:本文中的org.eclipse.swt.widgets.Tree.getItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。