use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ChangedListViewImpl method getCommonPath.
private String getCommonPath(String firstPath, String secondPath) {
Path commonPath = Path.valueOf(firstPath);
int segmentCount = commonPath.segmentCount();
for (int i = 1; i < segmentCount; i++) {
String path = commonPath.removeLastSegments(segmentCount - i).toString();
if (!secondPath.startsWith(path)) {
return Path.valueOf(path).removeLastSegments(1).toString();
}
}
return commonPath.toString();
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ComparePresenter method showCompareWithLatest.
/**
* Show compare window.
*
* @param file
* file name with its full path
* @param status
* status of the file
* @param revision
* hash of revision or branch
*/
public void showCompareWithLatest(final File file, final Status status, final String revision) {
this.comparedFile = file;
this.revision = revision;
this.compareWithLatest = true;
if (status.equals(ADDED)) {
showCompare("");
return;
}
final Optional<Project> project = file.getRelatedProject();
if (!project.isPresent()) {
return;
}
final Path relPath = file.getLocation().removeFirstSegments(project.get().getLocation().segmentCount());
if (status.equals(DELETED)) {
service.showFileContent(appContext.getDevMachine(), project.get().getLocation(), relPath, revision).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse content) throws OperationException {
view.setTitle(file.getLocation().toString());
view.setColumnTitles(locale.compareYourVersionTitle(), revision + locale.compareReadOnlyTitle());
view.show(content.getContent(), "", file.getLocation().toString(), false);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
} else {
service.showFileContent(appContext.getDevMachine(), project.get().getLocation(), relPath, revision).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse content) throws OperationException {
showCompare(content.getContent());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class EditorContentSynchronizerImplTest method init.
@Before
public void init() {
activeEditor = mock(EditorPartPresenter.class, withSettings().extraInterfaces(EditorWithAutoSave.class));
when(activeEditor.getEditorInput()).thenReturn(editorInput);
when(editorInput.getFile()).thenReturn(virtualFile);
when(virtualFile.getLocation()).thenReturn(new Path(FILE_PATH));
when(editorGroupSyncProvider.get()).thenReturn(editorGroupSynchronization);
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class EditorContentSynchronizerImplTest method shouldUpdatePathForGroupWhenFileLocationIsChanged.
@Test
public void shouldUpdatePathForGroupWhenFileLocationIsChanged() {
Resource resource = mock(Resource.class);
ResourceDelta delta = mock(ResourceDelta.class);
ResourceChangedEvent resourceChangedEvent = new ResourceChangedEvent(delta);
Path fromPath = new Path(FILE_PATH);
Path toPath = new Path("testProject/src/main/java/org/eclipse/che/examples/changedFile");
EditorPartPresenter openedEditor1 = mock(EditorPartPresenter.class);
when(openedEditor1.getEditorInput()).thenReturn(editorInput);
when(delta.getKind()).thenReturn(ResourceDelta.ADDED);
when(delta.getFlags()).thenReturn(5632);
when(delta.getFromPath()).thenReturn(fromPath);
when(delta.getToPath()).thenReturn(toPath);
when(delta.getResource()).thenReturn(resource);
when(resource.isFile()).thenReturn(true);
editorContentSynchronizer.trackEditor(openedEditor1);
editorContentSynchronizer.onResourceChanged(resourceChangedEvent);
final EditorGroupSynchronization oldGroup = editorContentSynchronizer.editorGroups.get(fromPath);
final EditorGroupSynchronization newGroup = editorContentSynchronizer.editorGroups.get(toPath);
assertNull(oldGroup);
assertNotNull(newGroup);
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class FullTextSearchPresenterTest method viewShouldBeShowed.
@Test
public void viewShouldBeShowed() {
final Path path = Path.valueOf("/search");
fullTextSearchPresenter.showDialog(path);
verify(view).showDialog();
verify(view).clearInput();
verify(view).setPathDirectory(eq(path.toString()));
}
Aggregations