/** * Return an id for the registration in action manager. ID value forms based on file path to * define unique key for this action. * * @return action id */ public String getId() { return "recent/" + file.getLocation(); } }
protected Promise<String> read(File file) { return ps.getFileContent(file.getLocation()); }
protected Promise<Void> write(final File file, String content) { checkArgument(content != null, "Null content occurred"); return ps.setFileContent(file.getLocation(), content); }
@Inject public RecentFileAction(@Assisted File file, EditorAgent editorAgent) { super(singletonList(PROJECT_PERSPECTIVE_ID), getShortPath(file.getLocation().toString())); this.file = file; this.editorAgent = editorAgent; }
@Override public List<File> apply(Resource[] children) throws FunctionException { return Stream.of(children) .filter( child -> child.isFile() && endsWith(child.asFile().getLocation(), relativeFilePath)) .map(Resource::asFile) .collect(Collectors.toList()); } });
/** * A callback that is to be called for an anchor * * @param qualifiedName * @param fileName * @param lineNumber */ public void handleAnchorClick(String qualifiedName, String fileName, final int lineNumber) { if (qualifiedName == null || fileName == null) { return; } String qualifiedClassName = qualifiedName.lastIndexOf('.') != -1 ? qualifiedName.substring(0, qualifiedName.lastIndexOf('.')) : qualifiedName; final String packageName = qualifiedClassName.lastIndexOf('.') != -1 ? qualifiedClassName.substring(0, qualifiedClassName.lastIndexOf('.')) : ""; String relativeFilePath = (packageName.isEmpty() ? "" : (packageName.replace(".", "/") + "/")) + fileName; collectChildren(appContext.getWorkspaceRoot(), Path.valueOf(relativeFilePath)) .then( files -> { if (!files.isEmpty()) { openFileInEditorAndReveal( appContext, editorAgent, files.get(0).getLocation(), lineNumber, 0); } }); }
/** Open dialog and shows revisions to compare. */ public void showRevisions(Project project, File selectedFile) { this.project = project; checkState( project.getLocation().isPrefixOf(selectedFile.getLocation()), "Given selected file is not descendant of given project"); selectedFilePath = selectedFile .getLocation() .removeFirstSegments(project.getLocation().segmentCount()) .removeTrailingSeparator(); getRevisions(); }
@Override public void onGitStatusChanged(String endpointId, StatusChangedEventDto statusChangedEventDto) { Tree tree = projectExplorerPresenterProvider.get().getTree(); tree.getNodeStorage() .getAll() .stream() .filter( node -> node instanceof FileNode && statusChangedEventDto .getProjectName() .equals(getRootPath(((FileNode) node).getData().getLocation()))) .map(node -> (FileNode) node) .map(ResourceNode::getData) .map(Resource::getLocation) .map(Path::toString) .forEach( location -> treeChangeHandler.handleFileChange( dtoFactory .createDto(ProjectTreeStateUpdateDto.class) .withPath(location) .withType(FileWatcherEventType.MODIFIED))); } }
/** * A callback that is to be called for a compilation message anchor * * @param fileName * @param lineNumber * @param columnNumber */ public void handleCompilationMessageAnchorClick( String fileName, final int lineNumber, int columnNumber) { if (fileName == null) { return; } collectChildren(appContext.getWorkspaceRoot(), Path.valueOf(fileName)) .then( files -> { if (!files.isEmpty()) { openFileInEditorAndReveal( appContext, editorAgent, files.get(0).getLocation(), lineNumber, columnNumber); } }); }
private boolean isResourceOpened(final Resource resource) { if (!resource.isFile()) { return false; } File file = (File) resource; for (EditorPartPresenter editor : editorAgent.getOpenedEditors()) { Path editorPath = editor.getEditorInput().getFile().getLocation(); if (editorPath.equals(file.getLocation())) { return true; } } return false; }
@Override public void onFileChanged(String endpointId, FileChangedEventDto dto) { Tree tree = projectExplorerPresenterProvider.get().getTree(); tree.getNodeStorage() .getAll() .stream() .filter( node -> node instanceof FileNode && ((FileNode) node) .getData() .getLocation() .equals(Path.valueOf(dto.getPath()))) .forEach( node -> { ((FileNode) node) .getData() .asFile() .setVcsStatus(VcsStatus.from(dto.getStatus().toString())); tree.refresh(node); }); }
/** Saves given contents into file under edit. */ private void saveContent(final String content) { localContent = content; comparedFile .updateContent(content) .then( ignored -> { eventBus.fireEvent(new FileContentUpdateEvent(comparedFile.getLocation().toString())); }) .catchError( error -> { notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE); }); }
private void showCompare(final String remoteContent) { comparedFile .getContent() .then( local -> { localContent = local; final String path = comparedFile.getLocation().removeFirstSegments(1).toString(); view.setTitleCaption(getTitleForFile(path)); view.setColumnTitles( locale.compareYourVersionTitle(), revision + locale.compareReadOnlyTitle()); view.show(remoteContent, localContent, path, false); }); }
if ("php".equals(extension) || "phtml".equals(extension)) { enable = true; selectedNodePath = data.getLocation().toString();