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


Java TreePath.getSegment方法代碼示例

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


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

示例1: 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()]);
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:21,代碼來源:JavaProjectUtilities.java

示例2: 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();
		}
	}

}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:18,代碼來源:SimulationView.java

示例3: getQualifiedName

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * @param selections
 * @return
 */
public static String getQualifiedName(final ITreeSelection selections) {
  final TreePath[] paths = selections.getPaths();

  // Consider only not empty and single selection
  if (selections.isEmpty() || selections.size() > 1) {
    return null;
  }

  final TreePath path = paths[0];
  IElementComparer comparer = null;
  if (selections instanceof TreeSelection) {
    comparer = ((TreeSelection) selections).getElementComparer();
  }
  System.out.println(path.hashCode(comparer));
  for (int i = 1; i < path.getSegmentCount(); i++) {
    if (path.getSegment(i) instanceof ResourceFactoryImpl) {
      final EcoreResourceFactoryImpl eResourceFactory =
          (EcoreResourceFactoryImpl) path.getSegment(i);
      System.out
          .println(eResourceFactory.getClass().getName() + ": " + eResourceFactory.toString());
    } else if (path.getSegment(i) instanceof ENamedElement) {
      final ENamedElement namedElement = (ENamedElement) path.getSegment(i);
      System.out.println(namedElement.getClass().getName() + ": " + namedElement.getName());
    } else {
      System.out.println("?");
    }
  }
  return null;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:34,代碼來源:MarkerFactory.java

示例4: createTreePath

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private TreePath createTreePath(TreePath old, Object newElement) {
	int count = old.getSegmentCount();
	Object[] newObjects = new Object[count];
	for (int i = 0; i < count - 1; i++) {
		newObjects[i] = old.getSegment(i);
	}
	newObjects[count - 1] = newElement;
	return new TreePath(newObjects);
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:10,代碼來源:RenameSelectionState.java

示例5: showSimulationResults

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
protected void showSimulationResults() {
	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);
			resultViewer.setInput(simulationSuiteElement.getExperimentTags());
		} else {
			resultViewer.setInput(new LinkedList<>());
		}
	} else {
		resultViewer.setInput(new LinkedList<>());
	}
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:15,代碼來源:SimulationView.java

示例6: doEditExperiment

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
protected void doEditExperiment() {
	TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
	if ((paths != null)&&(paths.length>0)) {
		TreePath selected = paths[0];			
		if (selected.getSegmentCount()>=2) {
			ProjectSimulationSuite projectSuite = (ProjectSimulationSuite) selected.getSegment(0);
			SimulationSuiteElement simulationSuiteElement = (SimulationSuiteElement) selected.getSegment(1);
			NewExperimentDialog dialog = new NewExperimentDialog(util.getProjectModels(projectSuite.getProject()), suiteViewer.getControl().getShell(),true,simulationSuiteElement.getSimulationExperiment() );
			if (dialog.open()==Window.OK) {
				simulationSuiteElement.setExperiment( dialog.getSimulationExperiment() );
				suiteViewer.refresh();
			}
		}
	}
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:16,代碼來源:SimulationView.java

示例7: doCopyExperiment

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
protected void doCopyExperiment() {
	TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
	if ((paths != null)&&(paths.length>0)) {
		TreePath selected = paths[0];			
		if (selected.getSegmentCount()>=2) {
			ProjectSimulationSuite projectSuite = (ProjectSimulationSuite) selected.getSegment(0);
			SimulationSuiteElement simulationSuiteElement = (SimulationSuiteElement) selected.getSegment(1);
			projectSuite.add( simulationSuiteElement.getSimulationExperiment().copy() );
			suiteViewer.refresh();
		}
	}
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:13,代碼來源:SimulationView.java

示例8: doRemoveLaboratory

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
protected void doRemoveLaboratory() {
	TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
	if ((paths != null)&&(paths.length>0)) {
		TreePath selected = paths[0];			
		if (selected.getSegmentCount()>=2) {
			ProjectSimulationSuite projectSuite = (ProjectSimulationSuite) selected.getSegment(0);
			SimulationSuiteElement simulationSuiteElement = (SimulationSuiteElement) selected.getSegment(1);
			if (showConfirmMessage("Deleting simulation experiment...", "Selected simulation experiment will be deleted. Do you want to proceed?")) {
				projectSuite.remove( simulationSuiteElement );	
				suiteViewer.refresh();
			}
		}
	}
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:15,代碼來源:SimulationView.java

示例9: openTwin

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/** Expands the element with the same name in the given treeviewer.
 * @param selection TreeSelection
 * @param tv 
 */
private void openTwin(TreeSelection selection,
		TreeViewer tv) {
	TreePath[] path = selection.getPaths();
	BTSObjectTypeTreeNode nodeRight = (BTSObjectTypeTreeNode) tv.getInput();
	TreePath tp = path[0];
	List<BTSObjectTypeTreeNode> elements = new Vector<BTSObjectTypeTreeNode>(tp.getSegmentCount());
	for (int i = 0 ; i < tp.getSegmentCount(); i++)
	{
		BTSObjectTypeTreeNode leftNode = (BTSObjectTypeTreeNode) tp.getSegment(i);
		BTSObjectTypeTreeNode childRight = null;
		if (nodeRight != null)
		{
			for (BTSObjectTypeTreeNode c : nodeRight.getChildren())
			{
				if (c.getValue() != null && c.getValue().equals(leftNode.getValue()))
				{
					childRight = c;
					elements.add(childRight);
					break;
				}
			}
			nodeRight = childRight;
		}
	}
	tv.setExpandedElements(elements.toArray(new BTSObjectTypeTreeNode[elements.size()]));

}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:32,代碼來源:RelationSubjectObjectTypesSelectionComposite.java

示例10: getGroupsFromPath

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private static List<PlanAdvisorGroup> getGroupsFromPath(TreePath parentPath) {
	List<PlanAdvisorGroup> groups = new ArrayList<PlanAdvisorGroup>(parentPath.getSegmentCount());
	for (int i = 0 ; i < parentPath.getSegmentCount() ; i++) {
		Object segment = parentPath.getSegment(i);
		if (segment instanceof PlanAdvisorGroup) {
			PlanAdvisorGroup group = (PlanAdvisorGroup) segment;
			groups.add(group);
		} else {
			// Shouldn't be here
		}
	}
	return groups;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:14,代碼來源:ViolationContentProvider.java

示例11: createTreePath

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private TreePath createTreePath(TreePath old, Object newElement) {
	int count= old.getSegmentCount();
	Object[] newObjects= new Object[count];
	for (int i= 0; i < count - 1; i++) {
		newObjects[i]= old.getSegment(i);
	}
	newObjects[count - 1]= newElement;
	return new TreePath(newObjects);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:10,代碼來源:RenameSelectionState.java

示例12: groupByWorkingSets

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private Map<IWorkingSet, List<Object>> groupByWorkingSets(TreePath[] paths) {
	Map<IWorkingSet, List<Object>> result= new HashMap<IWorkingSet, List<Object>>();
	for (int i= 0; i < paths.length; i++) {
		TreePath path= paths[i];
		IWorkingSet ws= (IWorkingSet)path.getSegment(0);
		List<Object> l= result.get(ws);
		if (l == null) {
			l= new ArrayList<Object>();
			result.put(ws, l);
		}
		l.add(path.getSegment(1));
	}
	return result;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:15,代碼來源:WorkingSetDropAdapter.java

示例13: generateWatchExpression

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * Generate a Java expression that represents the selection.
 * 
 * e.g. if we selected the "foo" field of the 3rd object in an array called
 * "bar" inside an object called "baz", build "baz.bar[2].foo"
 * 
 * @param treePath
 *            the selection {@link TreePath} object
 * @return a Java expression that represents the selection
 * @throws DebugException
 */
private String generateWatchExpression(TreePath treePath) throws DebugException {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < treePath.getSegmentCount(); i++) {
        Object part = treePath.getSegment(i);
        if (part instanceof IJavaFieldVariable) {
            sb.append('.');
            sb.append(((IJavaFieldVariable) part).getName());
        } else if (part instanceof IJavaVariable) {
            sb.append(((IJavaVariable) part).getName());
        }
    }
    return sb.toString();
}
 
開發者ID:danielrozenberg,項目名稱:vebugger,代碼行數:25,代碼來源:VisualDetailPane.java

示例14: exportCSV

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
private void exportCSV(final ITreeSelection selection, final String selectedFilePath) {

		/*
		 * Write selected items into a csv file.
		 */
		Writer exportWriter = null;
		try {

			exportWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(selectedFilePath), UI.UTF_8));
			final StringBuilder sb = new StringBuilder();

			exportCSV_10_Header(exportWriter, sb);

			for (final TreePath treePath : selection.getPaths()) {

				// truncate buffer
				sb.setLength(0);

				final int segmentCount = treePath.getSegmentCount();

				for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) {

					final Object segment = treePath.getSegment(segmentIndex);
					final boolean isTour = segment instanceof TVITourBookTour;

					exportCSV_20_1stColumn(sb, segmentCount, segment, isTour);

					if (segment instanceof TVITourBookItem) {

						final TVITourBookItem tviItem = (TVITourBookItem) segment;

						// output data only for the last segment
						if (segmentCount == 1
								|| (segmentCount == 2 && segmentIndex == 1)
								|| (segmentCount == 3 && segmentIndex == 2)) {

							exportCSV_30_OtherColumns(sb, isTour, tviItem);
						}
					}
				}

				// end of line
				sb.append(net.tourbook.ui.UI.SYSTEM_NEW_LINE);
				exportWriter.write(sb.toString());
			}

		} catch (final IOException e) {
			StatusUtil.showStatus(e);
		} finally {
			Util.closeWriter(exportWriter);
		}
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:53,代碼來源:TourBookView.java

示例15: saveState_ExpandedItems

import org.eclipse.jface.viewers.TreePath; //導入方法依賴的package包/類
/**
 * Save state for expanded tree items.
 */
private void saveState_ExpandedItems() {

	final Object[] visibleExpanded = _tagViewer.getVisibleExpandedElements();

	if (visibleExpanded.length == 0) {
		Util.setState(_state, STATE_EXPANDED_ITEMS, new long[0]);
		return;
	}

	final TLongArrayList expandedItems = new TLongArrayList();

	final TreePath[] expandedOpenedTreePaths = net.tourbook.common.UI.getExpandedOpenedItems(
			visibleExpanded,
			_tagViewer.getExpandedTreePaths());

	for (final TreePath expandedPath : expandedOpenedTreePaths) {

		// start a new path, allways set it twice to have a even structure
		expandedItems.add(STATE_ITEM_TYPE_SEPARATOR);
		expandedItems.add(STATE_ITEM_TYPE_SEPARATOR);

		for (int segmentIndex = 0; segmentIndex < expandedPath.getSegmentCount(); segmentIndex++) {

			final Object segment = expandedPath.getSegment(segmentIndex);

			if (segment instanceof TVITagViewTagCategory) {

				expandedItems.add(STATE_ITEM_TYPE_CATEGORY);
				expandedItems.add(((TVITagViewTagCategory) segment).tagCategoryId);

			} else if (segment instanceof TVITagViewTag) {

				expandedItems.add(STATE_ITEM_TYPE_TAG);
				expandedItems.add(((TVITagViewTag) segment).tagId);

			} else if (segment instanceof TVITagViewYear) {

				expandedItems.add(STATE_ITEM_TYPE_YEAR);
				expandedItems.add(((TVITagViewYear) segment).getYear());

			} else if (segment instanceof TVITagViewMonth) {

				expandedItems.add(STATE_ITEM_TYPE_MONTH);
				expandedItems.add(((TVITagViewMonth) segment).getMonth());
			}
		}
	}

	Util.setState(_state, STATE_EXPANDED_ITEMS, expandedItems.toArray());
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:54,代碼來源:TaggingView.java


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