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


Java Tree.getSelection方法代码示例

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


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

示例1: removeSelectedPackage

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
private void removeSelectedPackage(SelectionEvent e, TreeViewer treeViewer) {
	Tree tree = getTree(e);
	if (tree == null) {
		return;
	}
	TreeItem[] selection = tree.getSelection();
	if (selection != null && selection.length > 0) {
		for (TreeItem item : selection) {
			TreeItem parent = item.getParentItem();
			if (parent == null) {
				removePackage(item);
				updatePageComplete(tree);
			} else {
				alert("请选择要删除的包!");
			}
		}
	} else {
		alert("请选择要删除的包!");
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:21,代码来源:SelectClassPage.java

示例2: copyTree

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします
 * 
 * @param header ヘッダー
 * @param tree ツリー
 */
public static void copyTree(String[] header, Tree tree) {
    TreeItem[] treeItems = tree.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TreeItem column : treeItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
 
开发者ID:sanaehirotaka,项目名称:logbook,代码行数:23,代码来源:TreeToClipboardAdapter.java

示例3: getSelectedRootItemFromMainTree

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
public TreeItem getSelectedRootItemFromMainTree(){
	Tree tree = this.getMainTree();
	if(tree == null){
		return null;
	}
	
	TreeItem [] items = tree.getSelection();
	if(items == null || items.length == 0){
		return null;
	}
	
	if(items[0].getData() instanceof StackAnalyzedInfo){
		return items[0].getParentItem();
	}
	return items[0];
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:17,代码来源:MainProcessor.java

示例4: getSelectedPropertyDescriptor

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * Gets the property descriptor of the selected property for this databaseObjectBeanInfo 
 * @param databaseObjectBeanInfo : BeanInfo of the selected databaseObject in the TreeExplorerView
 * @return PropertyDescriptor
 */
public PropertyDescriptor getSelectedPropertyDescriptor(BeanInfo databaseObjectBeanInfo) {
	PropertyDescriptor propertyDescriptor = null;
	
	// gets the properties editor
	PropertySheet view = ConvertigoPlugin.getDefault().getPropertiesView();
	Tree tree = (Tree) view.getCurrentPage().getControl();
	// gets the property selected in the property editor if one is selected
	TreeItem[] items = tree.getSelection();
	if (items.length > 0) {
		TreeItem selectedItem = items[0];
	
		// gets the local name of the selected property
		String text = selectedItem.getText();
        
        // gets the PropertyDescriptors of this databaseObject
        PropertyDescriptor[] descriptors = databaseObjectBeanInfo.getPropertyDescriptors();
        
        String displayName = null;
		int i = 0;
		
		// gets the PropertyDescriptor of the selected property 
		while (i < descriptors.length && propertyDescriptor == null) {
			displayName = descriptors[i].getDisplayName();
			if (displayName.equals(text))
				propertyDescriptor = descriptors[i];
			i++;
		}
	}	
	return propertyDescriptor;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:36,代码来源:ConvertigoPlugin.java

示例5: 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

示例6: refresh

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
protected void refresh() {
	if (orgsSpacesViewer != null) {

		Tree tree = orgsSpacesViewer.getTree();
		TreeItem[] selectedItems = tree.getSelection();
		if (selectedItems != null && selectedItems.length > 0) {
			// It's a single selection tree, so only get the first selection
			Object selectedObj = selectedItems[0].getData();
			CloudSpace selectedSpace = selectedObj instanceof CloudSpace ? (CloudSpace) selectedObj : null;
			setSpaceSelection(selectedSpace);
		}
	}
}
 
开发者ID:eclipse,项目名称:cft,代码行数:14,代码来源:CloudSpacesSelectionPart.java

示例7: createParent

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * create text editor parent.
 * 
 * @return Composite
 */
Composite createParent() {
    Tree tree = navigatorTree;
    Composite result = new Composite(tree, SWT.NONE);
    TreeItem[] selectedItems = tree.getSelection();

    if (selectedItems == null || selectedItems.length < 1) {
        return null;
    }

    treeEditor.horizontalAlignment = SWT.LEFT;
    treeEditor.grabHorizontal = true;
    treeEditor.setEditor(result, selectedItems[0]);
    return result;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:20,代码来源:RenameAction.java

示例8: getCurrentItem

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
private TreeItem getCurrentItem(boolean forward) {
	Tree tree = viewer.getTree();
	TreeItem[] selection = tree.getSelection();
	if (selection.length == 0) {
		selection = tree.getItems();
	}

	TreeItem nextItem = null;
	if (selection.length > 0) {
		nextItem = forward ? selection[0] : selection[selection.length - 1];
	}
	return nextItem;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:14,代码来源:TreeViewerNavigator.java

示例9: getSelectedItemFromMainTree

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
public TreeItem getSelectedItemFromMainTree(){
	Tree tree = this.getMainTree();
	if(tree == null){
		return null;
	}
	
	TreeItem [] items = tree.getSelection();
	if(items == null || items.length == 0){
		return null;
	}
	return items[0];
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:13,代码来源:MainProcessor.java

示例10: execute

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * Gets called if triggered
 *
 * @param event
 *            The {@link ExecutionEvent}
 */
public Object execute(ExecutionEvent event) throws ExecutionException {

    Event e = ((Event) event.getTrigger());
    Widget widget = e.widget;

    ISelectionService selectionService = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getSelectionService();
    ISelection selection = selectionService.getSelection();

    if (selection instanceof TextSelection && widget instanceof StyledText) { // Java-File
        TextSelection txtSel = (TextSelection) selection;
        IEditorPart activeEditor = PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getActivePage()
                .getActiveEditor();
        FileEditorInput input = (FileEditorInput) activeEditor
                .getEditorInput();
        IFile file = input.getFile();

        RBManager.getRefactorService().openRefactorDialog(file,
                txtSel.getOffset());
    }

    if (widget != null && widget instanceof Tree) { // Messages-Editor or
                                                    // TapiJI-View
        Tree tree = (Tree) widget;
        TreeItem[] treeItems = tree.getSelection();
        if (treeItems.length == 1) {
            TreeItem item = treeItems[0];
            Object data = item.getData();
            String oldKey = item.getText();
            if (data != null && data instanceof KeyTreeNode) {
            	oldKey = ((KeyTreeNode)data).getMessageKey();
            }
            if (tree.getData() instanceof AbstractKeyTreeModel) {
                AbstractKeyTreeModel model = (AbstractKeyTreeModel) tree
                        .getData();
                MessagesBundleGroup messagesBundleGroup = model
                        .getMessagesBundleGroup();
                String projectName = messagesBundleGroup.getProjectName();
                String resourceBundleId = messagesBundleGroup
                        .getResourceBundleId();

                RBManager.getRefactorService().openRefactorDialog(
                        projectName, resourceBundleId, oldKey, null);

            }
        }
    }

    return null;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:58,代码来源:RefactoringHandler.java

示例11: toggleMapVisibility

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * toggle visibility of the map provider or wms layer
 */
private void toggleMapVisibility(final Tree tree) {

	final TreeItem[] items = tree.getSelection();
	if (items.length > 0) {

		// get tree custom item
		final Object itemData = items[0].getData();

		if (itemData instanceof TVIMapProvider) {

			final MPWrapper mpWrapper = ((TVIMapProvider) itemData).getMapProviderWrapper();
			boolean isWmsDisplayed = mpWrapper.isDisplayedInMap();

			final MP mapProvider = mpWrapper.getMP();
			if (mapProvider instanceof MPWms) {

				// visibility for a wms map provider can be toggled only a layer

				if (isWmsDisplayed) {
					// hide wms
					isWmsDisplayed = false;
				} else {
					// show wms only when one layer is displayed
					isWmsDisplayed = canWmsBeDisplayed((MPWms) mapProvider);
				}

			} else {

				// toggle state

				isWmsDisplayed = !isWmsDisplayed;
			}

			if (isWmsDisplayed) {

				/*
				 * remove parent tiles from loading cache because they can have loading errors
				 * (from their children) which prevents them to be loaded again
				 */
				_mpProfile.resetParentTiles();
			}

			mpWrapper.setIsDisplayedInMap(isWmsDisplayed);
			enableProfileMapButton();

		} else if (itemData instanceof TVIWmsLayer) {

			final TVIWmsLayer tviLayer = (TVIWmsLayer) itemData;
			final MtLayer mtLayer = tviLayer.getMtLayer();

			// toggle layer state
			mtLayer.setIsDisplayedInMap(!mtLayer.isDisplayedInMap());

			// update parent state
			updateMVMapProvider(tviLayer);
		}

		// update viewer
		_treeViewer.update(itemData, null);

		updateLiveView();
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:67,代码来源:DialogMPProfile.java

示例12: toggleMapVisibility

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * toggle visibility of the map provider or wms layer
 */
private void toggleMapVisibility(final Tree tree) {

	final TreeItem[] items = tree.getSelection();
	if (items.length > 0) {

		// get tree custom item
		final Object itemData = items[0].getData();

		if (itemData instanceof TVIMapProvider) {

			final MPWrapper mpWrapper = ((TVIMapProvider) itemData).getMapProviderWrapper();
			boolean isWmsDisplayed = mpWrapper.isDisplayedInMap();

			final MP mapProvider = mpWrapper.getMP();
			if (mapProvider instanceof MPWms) {

				// visibility for a wms map provider can be toggled only a layer

				if (isWmsDisplayed) {
					// hide wms
					isWmsDisplayed = false;
				} else {
					// show wms only when one layer is displayed
					isWmsDisplayed = canWmsBeDisplayed((MPWms) mapProvider);
				}

			} else {

				// toggle state

				isWmsDisplayed = !isWmsDisplayed;
			}

			if (isWmsDisplayed) {

				/*
				 * remove parent tiles from loading cache because they can have loading
				 * errors (from their children) which prevents them to be loaded again
				 */
				_mpProfile.resetParentTiles();
			}

			mpWrapper.setIsDisplayedInMap(isWmsDisplayed);
			enableProfileMapButton();

		} else if (itemData instanceof TVIWmsLayer) {

			final TVIWmsLayer tviLayer = (TVIWmsLayer) itemData;
			final MtLayer mtLayer = tviLayer.getMtLayer();

			// toggle layer state
			mtLayer.setIsDisplayedInMap(!mtLayer.isDisplayedInMap());

			// update parent state
			updateMVMapProvider(tviLayer);
		}

		// update viewer
		_treeViewer.update(itemData, null);

		updateLiveView();
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:67,代码来源:DialogMPProfile.java

示例13: getSelectedElements

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * Return an array of the TreeItem selected in the tree 
 * 
 * @return a not null array of the selected element
 */
private TreeItem[] getSelectedElements(){
	Tree tree = (Tree) resourceList.getControl();
	return tree.getSelection();
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:10,代码来源:GetinputNewWizardPage.java


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