Java Code Examples for org.eclipse.core.runtime.IPath

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  23 
vote

/** 
 * This also changes the editor's input. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSaveAs(){
  SaveAsDialog saveAsDialog=new SaveAsDialog(getSite().getShell());
  saveAsDialog.open();
  IPath path=saveAsDialog.getResult();
  if (path != null) {
    IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    if (file != null) {
      doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),true),new FileEditorInput(file));
    }
  }
}
 

Example 2

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappEditor.java

  22 
vote

/** 
 * This also changes the editor's input. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSaveAs(){
  SaveAsDialog saveAsDialog=new SaveAsDialog(getSite().getShell());
  saveAsDialog.open();
  IPath path=saveAsDialog.getResult();
  if (path != null) {
    IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    if (file != null) {
      doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),true),new FileEditorInput(file));
    }
  }
}
 

Example 3

From project acceleo-webapp-generator, under directory /plugins/org.obeonetwork.pim.gen.backbone.model.editor/src-gen/org/obeonetwork/pim/gen/backbone/model/backbone/presentation/.

Source file: BackboneEditor.java

  22 
vote

/** 
 * This also changes the editor's input. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSaveAs(){
  SaveAsDialog saveAsDialog=new SaveAsDialog(getSite().getShell());
  saveAsDialog.open();
  IPath path=saveAsDialog.getResult();
  if (path != null) {
    IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    if (file != null) {
      doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),true),new FileEditorInput(file));
    }
  }
}
 

Example 4

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/launch/.

Source file: NDKLaunchDelegate.java

  22 
vote

@Override public void launch(ILaunchConfiguration config,String mode,ILaunch launch,IProgressMonitor monitor) throws CoreException {
  IPath adb=new Path(AdtPlugin.getOsAbsoluteAdb());
  CommandLauncher launcher=new CommandLauncher();
  launcher.execute(adb,new String[]{"version"},null,new Path("."),monitor);
  StringOutputStream out=new StringOutputStream();
  launcher.waitAndRead(out,out,monitor);
  String msg=out.getBuffer().toString();
}
 

Example 5

From project Archimedes, under directory /br.org.archimedes.core.tests/test/br/org/archimedes/.

Source file: FileLoader.java

  22 
vote

/** 
 * To be used when loading files so that they can be found both as plugin tests and normal unit tests.
 * @param filePath The filePath to the file to be loaded
 * @return An input stream for that file
 * @throws FileNotFoundException Thrown if the file cannot be found directly under that path.
 */
public static InputStream getReaderForFile(String filePath) throws FileNotFoundException {
  InputStream fileInput;
  try {
    Bundle bundle=Platform.getBundle(TESTS_PLUGIN_ID);
    IPath file=new Path(filePath);
    fileInput=FileLocator.openStream(bundle,file,false);
  }
 catch (  Throwable t) {
    fileInput=new FileInputStream("resources/" + filePath);
  }
  return fileInput;
}
 

Example 6

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.elasticbeanstalk/src/com/amazonaws/eclipse/elasticbeanstalk/.

Source file: EnvironmentBehavior.java

  22 
vote

@Override protected void publishModule(int publishKind,int deltaKind,IModule[] moduleTree,IProgressMonitor monitor) throws CoreException {
  trace("PublishModule:" + " (publishKind: " + WtpConstantsUtils.lookupPublishKind(publishKind) + " deltaKind: "+ WtpConstantsUtils.lookupDeltaKind(deltaKind)+ " moduleTree: "+ Arrays.asList(moduleTree)+ ")");
  if (publishKind == IServer.PUBLISH_AUTO)   return;
  if (publishKind == IServer.PUBLISH_INCREMENTAL && deltaKind == NO_CHANGE)   return;
  if (deltaKind == REMOVED)   return;
  IPath exportedWar=WTPWarUtils.exportProjectToWar(moduleTree[0].getProject(),getTempDirectory());
  monitor.worked(100);
  trace("Created war: " + exportedWar.toOSString());
  currentUpdateEnvironmentJob.setModuleToPublish(moduleTree[0],exportedWar);
  updateModuleState(moduleTree[0],IServer.STATE_STARTING,IServer.PUBLISH_STATE_NONE);
}
 

Example 7

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.elasticbeanstalk/src/com/amazonaws/eclipse/elasticbeanstalk/webproject/.

Source file: CreateNewAwsJavaWebProjectRunnable.java

  22 
vote

private IClasspathEntry findSdkClasspathEntry(IJavaProject javaProject) throws JavaModelException {
  IPath expectedPath=new AwsClasspathContainer(SdkManager.getInstance().getDefaultSdkInstall()).getPath();
  for (  IClasspathEntry entry : javaProject.getRawClasspath()) {
    if (entry.getPath().equals(expectedPath))     return entry;
  }
  return null;
}
 

Example 8

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/wizards/export/.

Source file: TraviandoExportWizard.java

  22 
vote

public BioNessieTraceLog createBioNessieTraceLogger(int index,IPath bioNessieFilePath,SimulationTraceJob traceJob){
  IPath numberPath=bioNessieFilePath.removeFileExtension();
  if (index > 0) {
    numberPath=numberPath.addFileExtension(Integer.toString(index));
  }
  numberPath=numberPath.addFileExtension("bn");
  IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(numberPath);
  String filePath=file.getLocation().toOSString();
  FileStringConsumer fsc=new FileStringConsumer(filePath);
  BioNessieTraceLog travLog=new BioNessieTraceLog(fsc,model.getSBAModel());
  travLog.setCompleteConsumer(true);
  traceJob.addOutputFile(file);
  return travLog;
}
 

Example 9

From project Bio-PEPA, under directory /uk.ac.ed.inf.common/src/uk/ac/ed/inf/common/launching/.

Source file: LaunchingUtils.java

  22 
vote

/** 
 * Gets the absolute path to this file. It changes location if cygwin is needed.
 * @param file
 * @return
 */
private static String getAbsoluteFilename(IFile file){
  IPath location=file.getLocation();
  if (Platform.getOS().equals(Platform.OS_WIN32)) {
    location=location.setDevice("/cygdrive/c:");
    return location.toString().replaceFirst("/cygdrive/c:","/cygdrive/c");
  }
 else {
    return location.toString();
  }
}
 

Example 10

From project bndtools, under directory /bndtools.core/src/bndtools/.

Source file: Central.java

  22 
vote

public static IPath toPath(File file) throws Exception {
  String path=file.getCanonicalPath();
  String workspacePath=getWorkspace().getBase().getAbsolutePath();
  if (path.startsWith(workspacePath))   path=path.substring(workspacePath.length());
 else   return null;
  IPath p=new Path(path);
  return p;
}
 

Example 11

From project bndtools, under directory /bndtools.core/src/bndtools/classpath/.

Source file: BndContainerInitializer.java

  22 
vote

protected static IPath fileToPath(File file) throws Exception {
  IPath path=Central.toPath(file);
  if (path == null)   path=Path.fromOSString(file.getAbsolutePath());
  RefreshFileJob refreshJob=new RefreshFileJob(file,false);
  if (refreshJob.needsToSchedule())   refreshJob.schedule(100);
  return path;
}
 

Example 12

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/.

Source file: BPMN2Editor.java

  22 
vote

/** 
 * Beware, creates a new input and changes this editor!
 */
private IEditorInput createNewDiagramEditorInput() throws CoreException {
  IPath fullPath=modelFile.getFullPath();
  modelUri=URI.createPlatformResourceURI(fullPath.toString(),true);
  IFolder folder=BPMN2DiagramCreator.getTempFolder(fullPath);
  diagramFile=BPMN2DiagramCreator.getTempFile(fullPath,folder);
  BPMN2DiagramCreator creator=new BPMN2DiagramCreator();
  creator.setDiagramFile(diagramFile);
  IEditorInput input=creator.createDiagram(false);
  diagramUri=creator.getUri();
  return input;
}
 

Example 13

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/.

Source file: BPMN2DiagramCreator.java

  22 
vote

/** 
 * Return the temporary file to be used as editor input. Conceptually, this is the "diagramFile" mentioned here which is just a placeholder for use by Graphiti as the DiagramEditorInput file.
 * @param fullPath - path of the actual BPMN2 model file
 * @param folder - folder containing the model file
 * @return an IFile for the temporary file. If the file exists, it is first deleted.
 */
public static IFile getTempFile(IPath fullPath,IFolder folder){
  IPath path=fullPath.removeFileExtension().addFileExtension(TEMPFILE_EXTENSION);
  IFile tempFile=folder.getFile(path.lastSegment());
  if (tempFile.exists()) {
    try {
      tempFile.delete(true,null);
    }
 catch (    CoreException e) {
      Activator.showErrorWithLogging(e);
    }
  }
  return tempFile;
}
 

Example 14

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/core/internal/analysis/.

Source file: AbstractBundleMakerArtifactContainer.java

  22 
vote

/** 
 * {@inheritDoc}
 */
@Override public IPath getFullPath(){
  if (hasParent() && !(getParent() instanceof IRootArtifact)) {
    IPath path=getParent().getFullPath();
    return path.append(getUniquePathIdentifier());
  }
 else {
    return new Path(getUniquePathIdentifier());
  }
}
 

Example 15

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/core/internal/analysis/.

Source file: AdapterType2IArtifact.java

  22 
vote

/** 
 * {@inheritDoc}
 */
@Override public IPath getFullPath(){
  if (hasParent()) {
    IPath path=getParent().getFullPath();
    return path.append(getUniquePathIdentifier());
  }
 else {
    return new Path(getUniquePathIdentifier());
  }
}
 

Example 16

From project ccw, under directory /ccw.core/src/java/ccw/.

Source file: ClojureProject.java

  22 
vote

public IFile getFileAny(IPath location){
  IPath ppath=ResourcesPlugin.getWorkspace().getRoot().getLocation();
  if (location.matchingFirstSegments(ppath) != ppath.segmentCount())   return null;
  IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(location.removeFirstSegments(ppath.segmentCount()));
  if (file.exists())   return file;
 else   return null;
}
 

Example 17

From project ccw, under directory /ccw.core/src/java/ccw/.

Source file: ClojureProject.java

  22 
vote

public IFile getFile(IPath location){
  IPath ppath=project.getLocation();
  if (location.matchingFirstSegments(ppath) != ppath.segmentCount())   return null;
  IFile file=project.getProject().getFile(location.removeFirstSegments(ppath.segmentCount()));
  if (file.exists())   return file;
 else   return null;
}
 

Example 18

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: CeylonEditor.java

  22 
vote

private void initializeParseController(){
  IEditorInput editorInput=getEditorInput();
  IFile file=getFile(editorInput);
  IPath filePath=getPath(editorInput);
  parseController=new CeylonParseController();
  IProject project=file != null && file.exists() ? file.getProject() : null;
  parseController.initialize(filePath,project,annotationCreator);
}
 

Example 19

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/explorer/.

Source file: PackageExplorerLabelProvider.java

  22 
vote

private String getNameDelta(IFolder parent,IPackageFragment fragment){
  IPath prefix=parent.getFullPath();
  IPath fullPath=fragment.getPath();
  if (prefix.isPrefixOf(fullPath)) {
    StringBuffer buf=new StringBuffer();
    for (int i=prefix.segmentCount(); i < fullPath.segmentCount(); i++) {
      if (buf.length() > 0)       buf.append('.');
      buf.append(fullPath.segment(i));
    }
    return buf.toString();
  }
  return fragment.getElementName();
}
 

Example 20

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/.

Source file: UIFunctions.java

  21 
vote

/** 
 * Returns the launch files available in the current workspace.
 * @return {@code File[]}; may be empty
 */
public static File[] getLaunchFiles(){
  IPath stateLocation=DebugPlugin.getDefault().getStateLocation();
  File file=stateLocation.toFile();
  if (!file.isDirectory()) {
    return emptyList().toArray(new File[0]);
  }
  file=new File(file,".launches");
  if (!file.isDirectory()) {
    return emptyList().toArray(new File[0]);
  }
  File[] files=file.listFiles(new LaunchFilter());
  if (noItems(files)) {
    return emptyList().toArray(new File[0]);
  }
  List<File> ret=new ArrayList<File>();
  for (  final File f : files) {
    Properties p=new Properties();
    try {
      p.load(new FileReader(f));
    }
 catch (    IOException e) {
      continue;
    }
    Object obj=p.get("<launchConfiguration");
    if ((obj == null) || !(obj instanceof String)) {
      continue;
    }
    String s=(String)obj;
    if (s.contains("bel.editor")) {
      ret.add(f);
    }
  }
  return ret.toArray(new File[0]);
}
 

Example 21

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/wizards/.

Source file: ImportWizard.java

  21 
vote

@Override public boolean canFinish(){
  if (noLength(page.getSelectedDocument())) {
    return false;
  }
  IPath path=page.getContainerFullPath();
  IWorkspace w=getWorkspace();
  if (w == null) {
    page.setErrorMessage("No usable workspace.");
    return false;
  }
  IWorkspaceRoot root=w.getRoot();
  String _0=path.segment(0);
  IProject prj=root.getProject(_0);
  if (!getDefault().isOpenBELProject(prj)) {
    page.setErrorMessage("Select a BEL Editor project.");
    return false;
  }
  if (path.segmentCount() != 2) {
    page.setErrorMessage("Parent folder must be a document group.");
    return false;
  }
  if (noLength(page.getNewFileName())) {
    page.setErrorMessage("Enter a new file name.");
    return false;
  }
  return super.canFinish();
}
 

Example 22

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/dialog/field/.

Source file: FileSelector.java

  21 
vote

/** 
 * Opens a dialog and lets the user select a file from the current project. The code attempts to find the file "currentFile" which is assumed to be relative to the current directory and select it. The returned file name is relative to the current directory.
 * @param shell shell
 * @param preSelectFile a file path and name to preselect
 * @param validator file validator for the file dialog
 * @param filter filters objects in the selection dialog
 * @param project project to be displayed in selection dialog
 * @param directory directory to be pre-selected in the selection dialog
 * @return
 */
public static String getFile(Shell shell,String preSelectFile,ISelectionStatusValidator validator,ViewerFilter filter,IProject project,IContainer directory){
  String path=null;
  IFile file=null;
  if (preSelectFile != null) {
    IResource res=directory.findMember(preSelectFile);
    if (res != null && res.exists() && res instanceof IFile)     file=(IFile)res;
  }
  IFile newFile=selectFile(shell,"File selection","Select a file.",filter,project,file);
  if (newFile != null) {
    IPath projPath=newFile.getProjectRelativePath();
    if (directory.getProjectRelativePath().isPrefixOf(projPath))     projPath=projPath.removeFirstSegments(directory.getProjectRelativePath().segmentCount());
    path=projPath.toString();
  }
  return path;
}
 

Example 23

From project CBCJVM, under directory /eclipse/src/cbclipse/builder/.

Source file: CBCNature.java

  21 
vote

public void configure() throws CoreException {
  IProjectDescription desc=project.getDescription();
  ICommand[] commands=desc.getBuildSpec();
  for (int i=0; i < commands.length; ++i) {
    if (commands[i].getBuilderName().equals(CBCBuilder.BUILDER_ID)) {
      return;
    }
  }
  ICommand[] newCommands=new ICommand[commands.length + 1];
  System.arraycopy(commands,0,newCommands,0,commands.length);
  ICommand command=desc.newCommand();
  command.setBuilderName(CBCBuilder.BUILDER_ID);
  newCommands[newCommands.length - 1]=command;
  desc.setBuildSpec(newCommands);
  project.setDescription(desc,null);
  IJavaProject javaProject=JavaCore.create(project);
  Set<IClasspathEntry> entries=new HashSet<IClasspathEntry>();
  entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
  String osPath=Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.P_PATH);
  IPath path=Path.fromOSString(osPath);
  LibraryLocation location=new LibraryLocation(path,Path.EMPTY,Path.EMPTY);
  entries.add(JavaCore.newLibraryEntry(location.getSystemLibraryPath(),null,null));
  javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]),new NullProgressMonitor());
  IFile commCBC=project.getFile("comm.cbc");
  commCBC.create(new ByteArrayInputStream(new byte[]{}),true,new NullProgressMonitor());
}
 

Example 24

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/build/.

Source file: NDKCommandLauncher.java

  19 
vote

@Override public Process execute(IPath commandPath,String[] args,String[] env,IPath changeToDirectory,IProgressMonitor monitor) throws CoreException {
  if (Platform.getOS().equals(Platform.OS_WIN32) || Platform.getOS().equals(Platform.OS_MACOSX)) {
    String command=commandPath.toString();
    for (    String arg : args)     command+=" " + arg;
    commandPath=new Path("sh");
    args=new String[]{"-c",command};
  }
  return super.execute(commandPath,args,env,changeToDirectory,monitor);
}
 

Example 25

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/domain/.

Source file: SenecaJobSpecification.java

  19 
vote

public Map<String,IPath> getJudgesData(){
  Nodes result=root.query("./sjs:judge",context);
  Map<String,IPath> judgesData=new HashMap<String,IPath>();
  for (int i=0; i < result.size(); i++) {
    if (((Element)result.get(i)).getAttribute("data") != null) {
      judgesData.put(((Element)result.get(i)).getAttribute("id").getValue(),new Path(((Element)result.get(i)).getAttribute("data").getValue()));
    }
  }
  return judgesData;
}
 

Example 26

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/judge/.

Source file: Abstract13CJudge.java

  19 
vote

@Override public IJudge createJudge(IPath data) throws MissingInformationException {
  try {
    this.setData(data);
    CMLBuilder builder=new CMLBuilder();
    Document doc=builder.buildEnsureCML(ResourcesPlugin.getWorkspace().getRoot().getFile(this.getData()).getContents());
    SpectrumUtils.namespaceThemAll(doc.getRootElement().getChildElements());
    doc.getRootElement().setNamespaceURI(CMLUtil.CML_NS);
    Element element=builder.parseString(doc.toXML());
    if (element instanceof CMLCml)     this.configure((CMLCml)element);
 else     if (element instanceof CMLSpectrum) {
      CMLCml cmlcml=new CMLCml();
      cmlcml.appendChild(element);
      this.configure(cmlcml);
    }
    this.setEnabled(super.getEnabled());
    return this;
  }
 catch (  IOException e) {
    throw new MissingInformationException("Could not read the cmlString.");
  }
catch (  ParsingException e) {
    throw new MissingInformationException("Could not parse the cmlString; " + e.getMessage());
  }
catch (  CoreException e) {
    throw new MissingInformationException(e.getMessage());
  }
}