當前位置: 首頁>>代碼示例>>Java>>正文


Java TreePath.getLastSegment方法代碼示例

本文整理匯總了Java中org.eclipse.jface.viewers.TreePath.getLastSegment方法的典型用法代碼示例。如果您正苦於以下問題:Java TreePath.getLastSegment方法的具體用法?Java TreePath.getLastSegment怎麽用?Java TreePath.getLastSegment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.viewers.TreePath的用法示例。


在下文中一共展示了TreePath.getLastSegment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getJavaElements

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
public static IJavaElement[] getJavaElements(final ITreeSelection selection) {
  if (selection == null) {
    return new IJavaProject[0];
  }
  final List<IJavaElement> projects = new ArrayList<>();
  for (final TreePath treePath : selection.getPaths()) {
    if (treePath.equals(TreePath.EMPTY)) {
      continue;
    }
    final Object lastSegment = treePath.getLastSegment();
    if (!(lastSegment instanceof IJavaElement)) {
      continue;
    }
    projects.add((IJavaElement) lastSegment);
  }
  return projects.toArray(new IJavaElement[projects.size()]);
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:18,代碼來源:JavaProjectUtilities.java

示例2: doubleClick

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
@Override
public void doubleClick(final DoubleClickEvent event) {
	// safety check first
	if (event == null || event.getSelection() == null || !(event.getSelection() instanceof TreeSelection)) {
		return;
	}
	final TreeSelection selection = (TreeSelection) event.getSelection();
	final TreePath[] paths = selection.getPaths();
	final TreePath treePath = paths[paths.length - 1];
	final Object segment = treePath.getLastSegment();

	final TreeItem[] items = viewer.getTree().getItems();
	final TreeItem item = getItem(items, segment);
	if (item != null) {
		item.setExpanded(!item.getExpanded());
		viewer.refresh();
	}
}
 
開發者ID:FI13,項目名稱:afbb-bibo,代碼行數:19,代碼來源:TreeCollapseExpandListener.java

示例3: copyTreeSelectionToClipboard

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private void copyTreeSelectionToClipboard() {
  ITreeSelection selection = (ITreeSelection) treeViewer.getSelection();
  TreePath[] paths = selection.getPaths();

  StringBuffer buf = new StringBuffer();

  for (TreePath path : paths) {
    LogEntry<?> entry = (LogEntry<?>) path.getLastSegment();
    buf.append(createTabString(path.getSegmentCount() - 1));
    buf.append(entry.toString());
    buf.append("\n");
  }

  if (buf.length() > 0) {
    buf.deleteCharAt(buf.length() - 1); // take off last \n
  }

  copyToClipboard(buf.toString());
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:20,代碼來源:LogContent.java

示例4: getExpandedOpenedItems

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * @param allVisibleItems
 * @param allExpandedItems
 * @return Returns {@link TreePath}'s which are expanded and open (not hidden).
 */
public static TreePath[] getExpandedOpenedItems(final Object[] allVisibleItems, final TreePath[] allExpandedItems) {

	final ArrayList<TreePath> expandedOpened = new ArrayList<TreePath>();

	for (final TreePath expandedPath : allExpandedItems) {

		/*
		 * The last expanded segment must be in the visible list otherwise it is hidden.
		 */
		final Object lastExpandedItem = expandedPath.getLastSegment();

		for (final Object visibleItem : allVisibleItems) {

			if (lastExpandedItem == visibleItem) {

				expandedOpened.add(expandedPath);
				break;
			}
		}
	}

	return expandedOpened.toArray(new TreePath[expandedOpened.size()]);
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:29,代碼來源:UI.java

示例5: updateLabel

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
public void updateLabel(ViewerLabel label, TreePath elementPath) {
	Object firstSegment = elementPath.getFirstSegment();
	if (firstSegment instanceof IProject && elementPath.getSegmentCount() == 2) {
		IProject project = (IProject) firstSegment;
		Object lastSegment = elementPath.getLastSegment();
		if (lastSegment instanceof IFolder) {
			IFolder folder = (IFolder) lastSegment;
			if (!folder.getParent().equals(project)) {
				// This means that a folder that is not a direct child of the project
				// is a child in the tree. Therefore, the resource content provider
				// must be active and in compress folder mode so we will leave
				// it to the resource provider to provide the proper label.
				// We need to do this because of bug 153912
				return;
			}
		}
	}
	label.setImage(getImage(elementPath.getLastSegment()));
	label.setText(getText(elementPath.getLastSegment()));
	Font f = getFont(elementPath.getLastSegment());
	if (f != null)
		label.setFont(f);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:24,代碼來源:JavaSynchronizationLabelProvider.java

示例6: save

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * Saves some selection in the memento object.
 */
private void save(TreePath treePath, String type) {
    if (treePath != null) {
        Object object = treePath.getLastSegment();
        if (object instanceof IAdaptable) {
            IAdaptable adaptable = (IAdaptable) object;
            IResource resource = (IResource) adaptable.getAdapter(IResource.class);
            if (resource != null) {
                IPath path = resource.getLocation();
                if (path != null) {
                    memento.createChild(type, path.toPortableString());
                }
            }
        }
    }
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:19,代碼來源:PyPackageStateSaver.java

示例7: traverseBreadthFirst

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private void traverseBreadthFirst(final TreePath root, final IProgressMonitor monitor) {
    final Queue<TreePath> q = new LinkedList<>();
    q.add(root);
    while (!q.isEmpty()) {
        final TreePath treePath = q.remove();
        if (treePath.getSegmentCount() > MAX_BREADTH_FIRST_TRAVERSAL_DEPTH) {
            traverseDepthFirst(treePath, monitor);
            while (!q.isEmpty()) {
                traverseDepthFirst(q.remove(), monitor);
            }
        } else {
            final Object o = treePath.getLastSegment();
            if (itIsAMatch(o)) {
                reveal(treePath);
            }
            final Object[] children = getChildren(o);
            checkCanceled(monitor);
            for (final Object child : children) {
                q.add(treePath.createChildPath(child));
            }
        }
    }
}
 
開發者ID:info-sharing-environment,項目名稱:NIEM-Modeling-Tool,代碼行數:24,代碼來源:NiemCheckedTreeSelectionDialog.java

示例8: hasParentTypeScriptFile

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private boolean hasParentTypeScriptFile(Object parent) {
	if (parent instanceof TreePath) {
		TreePath treePath = (TreePath) parent;
		Object segment = treePath.getLastSegment();
		if (segment == null) {
			return false;
		}
		return TypeScriptResourceUtil.isTsOrTsxFile(segment);
	}
	return false;
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:12,代碼來源:TypeScriptFilter.java

示例9: updateLabel

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * @generated
 */
public void updateLabel(ViewerLabel label, TreePath elementPath) {
	Object element = elementPath.getLastSegment();
	if (element instanceof StatemachineNavigatorItem
			&& !isOwnView(((StatemachineNavigatorItem) element).getView())) {
		return;
	}
	label.setText(getText(element));
	label.setImage(getImage(element));
}
 
開發者ID:spoenemann,項目名稱:xtext-gef,代碼行數:13,代碼來源:StatemachineNavigatorLabelProvider.java

示例10: updateLabel

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
public void updateLabel(ViewerLabel label, TreePath elementPath) {
	Diagram lastSegment = (Diagram) elementPath.getLastSegment();
	NamedElement element = (NamedElement) lastSegment.getElement();
	AdapterFactoryLabelProvider provider = new AdapterFactoryLabelProvider(
			new SGraphItemProviderAdapterFactory());
	label.setText(provider.getText(element));
	if (element instanceof Statechart)
		label.setImage(StatechartImages.LOGO.image());
	else
		label.setImage(provider.getImage(element));

}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:13,代碼來源:DiagramPartitioningEditor.java

示例11: select

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
@Override
public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
	if (parentElement instanceof TreePath && ResourceManager.isFile(element)) {
		final TreePath p = (TreePath) parentElement;
		if (p.getLastSegment() instanceof WrappedFolder) {
			final IResource r = FileMetaDataProvider.shapeFileSupportedBy(ResourceManager.getFile(element));
			if (r != null) { return false; }
		}
	}
	return true;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:12,代碼來源:NavigatorFilter.java

示例12: getWorkbenchWindowSelection

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private IPath getWorkbenchWindowSelection() {
	IWorkbenchWindow window= fWorkbench.getActiveWorkbenchWindow();
	if (window != null) {
		ISelection selection= window.getSelectionService().getSelection();
		if (selection instanceof IStructuredSelection) {
			IStructuredSelection structuredSelection= (IStructuredSelection) selection;
			Object element= structuredSelection.getFirstElement();
			if (element != null) {
				Object resource= Platform.getAdapterManager().getAdapter(element, IResource.class);
				if (resource != null) {
					return ((IResource) resource).getFullPath();
				}
				if (structuredSelection instanceof ITreeSelection) {
					TreePath treePath= ((ITreeSelection) structuredSelection).getPaths()[0];
					while ((treePath = treePath.getParentPath()) != null) {
						element= treePath.getLastSegment();
						resource= Platform.getAdapterManager().getAdapter(element, IResource.class);
						if (resource != null) {
							return ((IResource) resource).getFullPath();
						}
					}
				}
			}
			
		}
	}
	return null;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:29,代碼來源:UserLibraryPreferencePage.java

示例13: updateLabel

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * @generated
 */
public void updateLabel(ViewerLabel label, TreePath elementPath) {
	Object element = elementPath.getLastSegment();
	if (element instanceof SmcNavigatorItem
			&& !isOwnView(((SmcNavigatorItem) element).getView())) {
		return;
	}
	label.setText(getText(element));
	label.setImage(getImage(element));
}
 
開發者ID:road-framework,項目名稱:ROADDesigner,代碼行數:13,代碼來源:SmcNavigatorLabelProvider.java

示例14: updateLabel

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * @generated
 */
public void updateLabel(ViewerLabel label, TreePath elementPath) {
	Object element = elementPath.getLastSegment();
	if (element instanceof Wc2014NavigatorItem
			&& !isOwnView(((Wc2014NavigatorItem) element).getView())) {
		return;
	}
	label.setText(getText(element));
	label.setImage(getImage(element));
}
 
開發者ID:ggxx,項目名稱:HelloBrazil,代碼行數:13,代碼來源:Wc2014NavigatorLabelProvider.java

示例15: updateLabel

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * @generated
 */
public void updateLabel(ViewerLabel label, TreePath elementPath) {
	Object element = elementPath.getLastSegment();
	if (element instanceof SimpleBPMN.diagram.navigator.SimpleBPMNNavigatorItem
			&& !isOwnView(((SimpleBPMN.diagram.navigator.SimpleBPMNNavigatorItem) element)
					.getView())) {
		return;
	}
	label.setText(getText(element));
	label.setImage(getImage(element));
}
 
開發者ID:bluezio,項目名稱:simplified-bpmn-example,代碼行數:14,代碼來源:SimpleBPMNNavigatorLabelProvider.java


注:本文中的org.eclipse.jface.viewers.TreePath.getLastSegment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。