private boolean isJavaTestFile(Resource resource) { if (resource.getResourceType() != FILE) { return false; } final String ext = ((File) resource).getExtension(); return newHashSet("java", "class", "xml").contains(ext); } }
/** * 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(); } }
@Nullable @Override public String apply(@Nullable Resource input) { checkNotNull(input); if (input.isFile()) { return input.asFile().getNameWithoutExtension(); } return input.getName(); } };
/** * Returns the root project for the given file resource or null if the file isn't in a project. */ @Nullable public static Container getRootProject(final File file) { Container project = file.getProject(); Container parentProject = file.getParent(); while (parentProject != null) { project = parentProject; parentProject = parentProject.getParent(); } return project; }
FileNode fileNode = (FileNode) possibleNode; File data = fileNode.getData(); String extension = data.getExtension(); if ("php".equals(extension) || "phtml".equals(extension)) { enable = true; selectedNodePath = data.getLocation().toString();
@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); }); }
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); }); }
/** 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); }); }
VcsStatus oldVcsStatus = resource.asFile().getVcsStatus(); VcsStatus newVcsStatus = vcsStatusMap.remove(resource.getName()); resource.asFile().setVcsStatus(newVcsStatus);
@Override public void onFileChanged(String endpointId, FileChangedEventDto dto) { editorAgentProvider .get() .getOpenedEditors() .stream() .filter( editor -> editor.getEditorInput().getFile().getLocation().equals(Path.valueOf(dto.getPath())) && editor instanceof HasVcsChangeMarkerRender) .forEach( editor -> { VcsChangeMarkerRender render = ((HasVcsChangeMarkerRender) editor).getVcsChangeMarkersRender(); if (((File) editor.getEditorInput().getFile()).getVcsStatus() != MODIFIED) { render.clearAllChangeMarkers(); } else { handleEditedRegions(dto.getEditedRegions(), render); } }); }
private void updateContentInCompareWidget(PreviewNode selectedNode, List<TextEdit> edits) { String path = selectedNode.getUri(); Container workspaceRoot = appContext.getWorkspaceRoot(); Promise<Optional<File>> file = workspaceRoot.getFile(path); file.then( fileOptional -> { if (!fileOptional.isPresent()) { return; } File existingFile = fileOptional.get(); existingFile .getContent() .then( content -> { ChangePreview changePreview = new ChangePreview(); changePreview.setFileName(existingFile.getName()); changePreview.setOldContent(content); // apply all related TextEdit to show new content in compare widget StringBuilder output = new StringBuilder(); new StringStreamEditor(edits, content, output).transform(); String result = output.toString(); changePreview.setNewContent(result); view.showDiff(changePreview); }); }); }
@Override public void actionPerformed(ActionEvent e) { final Resource selectedResource = appContext.getResource(); if (Resource.FILE == selectedResource.getResourceType()) { final String contentUrl = ((File) selectedResource).getContentUrl(); BrowserUtils.openInNewTab(agentURLModifier.modify(contentUrl)); } } }
@Override public void onFileChanged(String endpointId, FileChangedEventDto dto) { editorAgentProvider .get() .getOpenedEditors() .stream() .filter( editor -> editor.getEditorInput().getFile().getLocation().equals(Path.valueOf(dto.getPath())) && editor instanceof HasVcsChangeMarkerRender) .forEach( editor -> { VcsStatus vcsStatus = VcsStatus.from(dto.getStatus().toString()); // set vcs status to editor file ((File) editor.getEditorInput().getFile()).setVcsStatus(vcsStatus); EditorTab tab = multiPartStackProvider.get().getTabByPart(editor); if (vcsStatus != null) { tab.setTitleColor(vcsStatus.getColor()); } }); }
final Project project = ((File) file).getProject();
if (getData().isFile() && getData().asFile().getVcsStatus() != null) { VcsStatus vcsStatus = getData().asFile().getVcsStatus(); if (vcsStatus != NOT_MODIFIED) { presentation.setPresentableTextCss("color: " + vcsStatus.getColor() + ";");
@Override public void actionPerformed(ActionEvent e) { final Resource selectedResource = appContext.getResource(); if (Resource.FILE == selectedResource.getResourceType()) { final String contentUrl = ((File) selectedResource).getContentUrl(); BrowserUtils.openInNewTab(agentURLModifier.modify(contentUrl)); } } }
/** * Returns the {@code true} if given {@code resource} is Java based file. * * <p>Java based file should has {@code .java} or {@code .class} extension. * * @param resource the resource to check * @return {@code true} if resource is java file, otherwise {@code false} * @throws IllegalArgumentException in case if given {@code resource} is null. Reason includes: * <ul> * <li>Null resource occurred * </ul> * * @since 4.4.0 */ public static boolean isJavaFile(Resource resource) { checkArgument(resource != null, "Null resource occurred"); if (resource.getResourceType() == FILE) { final String ext = ((File) resource).getExtension(); return !isNullOrEmpty(ext) && "java".equals(ext) || "class".equals(ext); } return false; }
protected Promise<String> read(File file) { return ps.getFileContent(file.getLocation()); }
/** {@inheritDoc} */ @Override public void intercept(Resource resource) { if (resource.isFile() && isJavaFile(resource)) { resource.addMarker(new PresentableTextMarker(((File) resource).getNameWithoutExtension())); } } }
optional -> { if (optional.isPresent()) { editorTab.setTitleColor(optional.get().getVcsStatus().getColor());