本文整理匯總了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()]);
}
示例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();
}
}
示例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());
}
示例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()]);
}
示例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());
}
}
}
}
}
示例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;
}
示例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));
}
示例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));
}
示例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;
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}