本文整理匯總了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;
}
}