protected static IFile getFileFor(IStructuredModel model) { if (model == null) return null; String path = model.getBaseLocation(); if (path == null || path.length() == 0) { Object id = model.getId(); if (id == null) return null; path = id.toString(); } // TODO needs rework for linked resources IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile file = root.getFileForLocation(new Path(path)); return file; }
/** * this method is copied from ModelManagerImpl of wtp. Because it is * internal. * * @param model * @return null if can't get file. */ // TODO: replace (or supplement) this is a "model info" association to the // IFile that created the model public static IFile getFileFor(IStructuredModel model) { if (model == null) return null; String path = model.getBaseLocation(); if (path == null || path.length() == 0) { Object id = model.getId(); if (id == null) return null; path = id.toString(); } // TODO needs rework for linked resources IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); try { IFile file = root.getFile(new Path(path)); // IFile file = root.getFileForLocation(new Path(path)); return file; } catch (Exception ex) { return null; } }
if ((modelBaseLocation == null) || (modelBaseLocation.length() == 0)) { modelBaseLocation = baseModel.getId();
if ((modelBaseLocation == null) || (modelBaseLocation.length() == 0)) { modelBaseLocation = baseModel.getId();