本文整理汇总了Java中org.eclipse.jface.viewers.TreePath.getFirstSegment方法的典型用法代码示例。如果您正苦于以下问题:Java TreePath.getFirstSegment方法的具体用法?Java TreePath.getFirstSegment怎么用?Java TreePath.getFirstSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.TreePath
的用法示例。
在下文中一共展示了TreePath.getFirstSegment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: SelectObject
import org.eclipse.jface.viewers.TreePath; //导入方法依赖的package包/类
public SelectObject(ExecutionEvent event, String outputFolder) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof TreeSelection) {
TreeSelection tselection = (TreeSelection) selection;
TreePath[] paths = tselection.getPaths();
TreePath path = paths[0];
Object firstSegment = path.getFirstSegment();
if (firstSegment instanceof IProject) {
project = (IProject) path.getFirstSegment();
javaProject = JavaCore.create(project);
} else if (firstSegment instanceof IJavaProject) {
javaProject = (IJavaProject) path.getFirstSegment();
project = javaProject.getProject();
}
IFolder source = project.getFolder(outputFolder);
IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(source);
packageRoot = root;
Object o = tselection.getFirstElement();
if (o instanceof IFile) {
this.file = (IFile) o;
}
}
}
示例3: doAddExperiment
import org.eclipse.jface.viewers.TreePath; //导入方法依赖的package包/类
protected void doAddExperiment() {
TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
if ((paths != null)&&(paths.length>0)) {
TreePath selected = paths[0];
ProjectSimulationSuite projectSuite = ((ProjectSimulationSuite) selected.getFirstSegment());
NewExperimentDialog dialog = new NewExperimentDialog(util.getProjectModels(projectSuite.getProject()), suiteViewer.getControl().getShell(),true);
if (dialog.open()==Window.OK) {
projectSuite.add( dialog.getSimulationExperiment() );
suiteViewer.refresh();
}
}
}
示例4: doSaveLaboratory
import org.eclipse.jface.viewers.TreePath; //导入方法依赖的package包/类
protected void doSaveLaboratory() {
TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
if ((paths != null)&&(paths.length>0)) {
TreePath selected = paths[0];
ProjectSimulationSuite projectSuite = (ProjectSimulationSuite) selected.getFirstSegment();
util.saveProjectSimulationSuite( projectSuite );
}
}
示例5: select
import org.eclipse.jface.viewers.TreePath; //导入方法依赖的package包/类
@Override
protected boolean select(Viewer viewer, Object parentElement, PyVariable variable, String variableName) {
if (variableName != null && variableName.startsWith("_")) {
// although we want to exclude _ names, don't do that on self and cls
if (parentElement instanceof TreePath) {
TreePath path = (TreePath) parentElement;
if (path.getSegmentCount() == 1) {
Object segment = path.getFirstSegment();
if (segment instanceof PyVariableCollection) {
PyVariableCollection varCol = (PyVariableCollection) segment;
try {
String varColName = varCol.getName();
if ("self".equals(varColName) || "cls".equals(varColName)) {
// Keep this, it is private to "us" so the user probably want to see it
return true;
}
} catch (DebugException e) {
// If we aren't able to get a name, play it safe and don't
// hide it from the user
return true;
}
}
}
}
// The variable isn't part of "self" or "cls", filter it out
return false;
}
return true;
}
示例6: doExportExperimentData
import org.eclipse.jface.viewers.TreePath; //导入方法依赖的package包/类
protected void doExportExperimentData() {
try {
TreePath[] paths = suiteViewer.getStructuredSelection().getPaths();
if ((paths != null)&&(paths.length>0)) {
TreePath selected = paths[0];
ProjectSimulationSuite projectSuite = (ProjectSimulationSuite) selected.getFirstSegment();
IFolder folder = projectSuite.getProject().getFolder("output");
if (!folder.exists()) {
folder.create(true, true,null);
}
SimulationOutcome result = (SimulationOutcome) resultViewer.getStructuredSelection().getFirstElement();
if (result != null) {
// DirectoryDialog dialog = new DirectoryDialog(suiteViewer.getControl().getShell(), SWT.SHEET);
// dialog.setMessage("Select the location");
// String locationstr = dialog.open();
// if (locationstr != null) {
// File parent = new File(locationstr);
for (SimulationTimeSeries serie : result.getCollectedData()) {
StringWriter sWriter = new StringWriter();
PrintWriter writer = new PrintWriter(sWriter);
// PrintWriter writer = new PrintWriter(new File(parent, serie.getName()+(result.getStartingTime().replace(' ', '_').replace('/', '_'))+".csv"));
serie.writeToCSV(writer);
writer.close();
IFile outputFile = projectSuite.getProject().getFile("output/"+serie.getName()+(result.getStartingTime().replace(' ', '_').replace('/', '_').replace(":",""))+".csv");
if (outputFile.exists()) {
outputFile.setContents( new ByteArrayInputStream(sWriter.toString().getBytes()) , true , false , null );
} else {
outputFile.create( new ByteArrayInputStream(sWriter.toString().getBytes()) , true , null);
}
}
MessageDialog.openInformation(
suiteViewer.getControl().getShell(),
"Info...",
"Data saved!");
// }
}
}
} catch (CoreException e) {
MessageDialog.openError(
suiteViewer.getControl().getShell(),
"Error...",
e.getMessage());
}
}
示例7: extractProjectAndFileFromInitiatingEvent
import org.eclipse.jface.viewers.TreePath; //导入方法依赖的package包/类
private boolean extractProjectAndFileFromInitiatingEvent(ExecutionEvent event) {
this.window = HandlerUtil.getActiveWorkbenchWindow(event);
this.activePage = this.window.getActivePage();
ISelection selection = this.activePage.getSelection();
if(selection instanceof ITreeSelection) {
TreeSelection treeSelection = (TreeSelection) selection;
TreePath[] treePaths = treeSelection.getPaths();
if(treePaths.length == 0) {
noProjectSelected();
return false;
}
TreePath treePath = treePaths[0];
Object firstSegmentObj = treePath.getFirstSegment();
this.project = (IProject) ((IAdaptable) firstSegmentObj).getAdapter(IProject.class);
if(this.project == null) {
noProjectSelected();
return false;
}
return true;
} else {
IEditorPart editor = this.activePage.getActiveEditor();
if(editor == null) {
noProjectSelected();
return false;
}
IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
IFile file = input.getFile();
this.project = file.getProject();
if(this.project == null) {
noProjectSelected();
return false;
}
return true;
}
}