public static File getBaseDir(Project project) { if (project == null) { return null; } Resource<?> root = project.getRoot(); if (root == null) { return null; } return ResourceUtil.getContextFile(root); }
protected boolean hasProjectFile(UIContext context, String fileName) { UISelection<Object> selection = context.getSelection(); if (selection != null) { Object object = selection.get(); if (object instanceof Resource) { File folder = ResourceUtil.getContextFile((Resource<?>) object); if (folder != null && Files.isDirectory(folder)) { File file = new File(folder, fileName); return file != null && file.exists() && file.isFile(); } } } return false; }
Resource<?> fileResource = root.getChild(fileName); if (fileResource != null) { File answer = ResourceUtil.getContextFile(fileResource); if (answer != null) { return answer; File folder = ResourceUtil.getContextFile(root); if (folder != null && Files.isDirectory(folder)) { return new File(folder, fileName); Object object = selection.get(); if (object instanceof Resource) { File folder = ResourceUtil.getContextFile((Resource<?>) object); if (folder != null && Files.isDirectory(folder)) { return new File(folder, fileName);
protected File getSelectionFolder(UIContext context) { UISelection<Object> selection = context.getSelection(); if (selection != null) { Object object = selection.get(); if (object instanceof Resource) { File folder = ResourceUtil.getContextFile((Resource<?>) object); if (folder != null && Files.isDirectory(folder)) { return folder; } } } return null; }