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


Java TreePath.getFirstSegment方法代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:ko2ic,項目名稱:comment-tag-gen-plugin,代碼行數:26,代碼來源:SelectObject.java

示例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();
		}
	}
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:13,代碼來源:SimulationView.java

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

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

示例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;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:30,代碼來源:ShowPrivateReferencesActionDelegate.java

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

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

示例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;
    }
}
 
開發者ID:MyChannel-Apps,項目名稱:Extensions,代碼行數:45,代碼來源:Emulator.java


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