本文整理匯總了Java中org.eclipse.jface.viewers.TreePath類的典型用法代碼示例。如果您正苦於以下問題:Java TreePath類的具體用法?Java TreePath怎麽用?Java TreePath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TreePath類屬於org.eclipse.jface.viewers包,在下文中一共展示了TreePath類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: selectTreePath
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
private boolean selectTreePath(Viewer viewer, TreePath parentPath, Object element) {
// Cut off children of elements that are shown repeatedly.
for (int i = 0; i < parentPath.getSegmentCount() - 1; i++) {
if (element.equals(parentPath.getSegment(i))) {
return false;
}
}
if (!(viewer instanceof TreeViewer)) {
return true;
}
if (matcher == null) {
return true;
}
TreeViewer treeViewer = (TreeViewer) viewer;
Boolean matchingResult = isMatchingOrNull(element);
if (matchingResult != null) {
return matchingResult;
}
return hasUnfilteredChild(treeViewer, parentPath, element);
}
示例2: getJavaProjects
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
public static IJavaProject[] getJavaProjects(final ITreeSelection treeSelection) {
if (treeSelection == null) {
return new IJavaProject[0];
}
final List<IJavaProject> projects = new ArrayList<>();
final TreePath[] paths = treeSelection.getPaths();
for (final TreePath treePath : paths) {
if (treePath.equals(TreePath.EMPTY)) {
continue;
}
for (int i = 0; i < treePath.getSegmentCount(); i++) {
final Object segment = treePath.getSegment(i);
if ((segment instanceof IJavaProject)) {
projects.add((IJavaProject) segment);
break;
}
}
}
return projects.toArray(new IJavaProject[projects.size()]);
}
示例3: 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()]);
}
示例4: computeEnablement
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
@Override
protected boolean computeEnablement(final IStructuredSelection selection) {
if (selection.size() != 1) {
return false;
}
// For VS 2010 the content provider is a TreeContentProvider. Only
// enable this action for history items at the root level. For
// versions prior to 2010 the condition for enablement conditions
// are unchanged.
boolean isRootItemSelected = true;
if (selection instanceof ITreeSelection) {
final ITreeSelection treeSelection = (ITreeSelection) selection;
final TreePath[] treePaths = treeSelection.getPaths();
if (treePaths.length == 1) {
isRootItemSelected = treePaths[0].getSegmentCount() == 1;
}
}
final String item = historyInput.getHistoryItem();
return !ServerPath.isServerPath(item) && isRootItemSelected;
}
示例5: setInput
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
public void setInput(PageRoot inputElement) {
input = inputElement;
if (viewer != null) {
Object[] expandedElements = viewer.getExpandedElements();
TreePath[] expandedTreePaths = viewer.getExpandedTreePaths();
viewer.setInput(input);
viewer.setExpandedElements(expandedElements);
viewer.setExpandedTreePaths(expandedTreePaths);
actions.get(ACTION_COPY).setEnabled(true);
actions.get(ACTION_CUT).setEnabled(true);
actions.get(ACTION_PASTE).setEnabled(true);
actions.get(ACTION_DELETE).setEnabled(true);
}
}
示例6: getExpandTreePaths
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
/**
* getExpandTreePaths
*
* @param tree
* @param selectedItem
* @return TreePath[]
*/
public static TreePath[] getExpandTreePaths(Tree tree, TreeItem selectedItem) {
ArrayList<Object> items = new ArrayList<Object>();
internalCollectTreeItems(items, tree);
ArrayList<Object> result = new ArrayList<Object>();
for (Iterator<Object> it = items.iterator(); it.hasNext();) {
Item item = (Item) it.next();
// if (item == selectedItem) {
TreePath treePath = getTreePathFromItem(item);
if (treePath != null) {
result.add(treePath);
}
// }
}
return (TreePath[]) result.toArray(new TreePath[items.size()]);
}
示例7: hierarchyCheck
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
/**
* hierarchyCheck
*
* @return boolean
*/
protected boolean hierarchyCheck() {
CommonViewer commonViewer = ViewerRegistry.getViewer();
TreeSelection sel = (TreeSelection) commonViewer.getSelection();
List<TreePath> pathList = Arrays.asList(sel.getPaths());
for (TreePath path : pathList) {
if (isContains(pathList, path.getParentPath())) {
MessageDialog.openError(ProjectExplorerPlugin.getShell(),
UMLMessage.LABEL_FILE_FRAGMENTATION,
UMLMessage.MESSAGE_FRAGMENT_DEFRAGMENT_ERROR_MESSAGE/*"패키지 간 상하 관계가 포함된 경우 일괄 단편화/병합을 실행할 수 없습니다."*/);
return false;
}
}
return true;
}
示例8: doRunSimulationExperiment
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
protected void doRunSimulationExperiment() {
TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
if ((paths != null)&&(paths.length>0)) {
TreePath selected = paths[0];
if (selected.getSegmentCount()>=2) {
SimulationSuiteElement simulationSuiteElement = (SimulationSuiteElement) selected.getSegment(1);
RunSimulationExperimentJob experiment = new RunSimulationExperimentJob(this, simulationSuiteElement);
//update the Lab View
//updateView();
experiment.setUser(true);
experiment.schedule();
}
}
}
示例9: refreshTreeViewer
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
private void refreshTreeViewer(final BTSCorpusObject btsCorpusObject) {
sync.asyncExec(new Runnable() {
public void run() {
if (!mainTreeViewer.getTree().isDisposed())
{
// mainTreeViewer
// .removeSelectionChangedListener(selectionListener);
for (TreePath path : mainTreeViewer.getExpandedTreePaths())
System.out.println(path.getLastSegment());
mainTreeViewer.refresh();
// mainTreeViewer.addSelectionChangedListener(selectionListener);
}
}
});
}
示例10: handleEvent
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
@Override
public void handleEvent(final Event event) {
// FIXME hack, should be solved be resetting the selection in viewer
// instead
btnToEdit.setEnabled(false);
btnUngroup.setEnabled(false);
final TreePath[] paths = xViewer.getSelection().getPaths();
if (paths.length > 0) {
final Copy copy = (Copy) paths[0].getLastSegment();
setInput(copy);
copies.remove(copy);
bindingContext.updateTargets();
checkGroups();
updateToListButton();
updateSaveButton();
xViewer.setInput(copies);
}
}
示例11: 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();
}
}
示例12: 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());
}
示例13: init
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
/**
* We will accept the selection in the workbench to see if we can initialize
* from it.
*
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
if (selection instanceof StructuredSelection) {
if (selection.getFirstElement() instanceof IProject || selection.getFirstElement() instanceof IFile || selection.getFirstElement() instanceof IFolder) {
this.selection = selection;
return;
}
for (Object obj : selection.toList()) {
if (obj instanceof EditPart) {
IEditorInput ein = SelectionHelper.getActiveJRXMLEditor().getEditorInput();
if (ein instanceof FileEditorInput) {
this.selection = new TreeSelection(new TreePath(new Object[] { ((FileEditorInput) ein).getFile() }));
return;
}
}
}
}
this.selection = selection;
}
示例14: init
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
if (selection instanceof StructuredSelection) {
if (selection.getFirstElement() instanceof IProject || selection.getFirstElement() instanceof IFile || selection.getFirstElement() instanceof IFolder) {
this.selection = selection;
return;
}
for (Object obj : selection.toList()) {
if (obj instanceof EditPart) {
IEditorInput ein = SelectionHelper.getActiveJRXMLEditor().getEditorInput();
if (ein instanceof FileEditorInput) {
this.selection = new TreeSelection(new TreePath(new Object[] { ((FileEditorInput) ein).getFile() }));
return;
}
}
}
}
this.selection = selection;
}
示例15: run
import org.eclipse.jface.viewers.TreePath; //導入依賴的package包/類
@Override
public void run() {
TreeSelection s = (TreeSelection) treeViewer.getSelection();
TreePath[] p = s.getPaths();
for (int i = 0; i < p.length;) {
final Object obj = p[i].getLastSegment();
if (obj instanceof ANode) {
ANode parent = (ANode) obj;
AddResourceWizard wizard = new AddResourceWizard(parent);
WizardDialog dialog = new WizardDialog(UIUtils.getShell(), wizard);
dialog.create();
dialog.open();
}
break;
}
}