use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class HistoryPresenterTest method disarm.
@Override
public void disarm() {
super.disarm();
Resource resource = mock(Resource.class);
when(resource.getLocation()).thenReturn(EMPTY);
when(appContext.getResource()).thenReturn(resource);
when(appContext.getRootProject()).thenReturn(project);
when(service.log(any(DevMachine.class), any(Path.class), any(Path[].class), anyInt(), anyInt(), anyBoolean())).thenReturn(logPromise);
when(service.diff(any(DevMachine.class), any(Path.class), anyList(), any(DiffType.class), anyBoolean(), anyInt(), anyString(), anyString())).thenReturn(stringPromise);
when(service.showFileContent(any(DevMachine.class), any(Path.class), any(Path.class), anyString())).thenReturn(showPromise);
when(stringPromise.then(any(Operation.class))).thenReturn(stringPromise);
when(stringPromise.catchError(any(Operation.class))).thenReturn(stringPromise);
when(logPromise.then(any(Operation.class))).thenReturn(logPromise);
when(logPromise.catchError(any(Operation.class))).thenReturn(logPromise);
when(constant.historyTitle()).thenReturn("title");
when(constant.historyNothingToDisplay()).thenReturn("error message");
when(constant.compareReadOnlyTitle()).thenReturn("(Read only)");
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class AddToIndexAction method addToIndex.
private void addToIndex(final GitOutputConsole console) {
Resource[] resources = appContext.getResources();
Path[] paths = new Path[resources.length];
for (int i = 0; i < resources.length; i++) {
Path path = resources[i].getLocation().removeFirstSegments(1);
paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
}
service.add(appContext.getDevMachine(), appContext.getRootProject().getLocation(), false, paths).then(voidArg -> {
console.print(constant.addSuccess());
notificationManager.notify(constant.addSuccess());
}).catchError(error -> {
console.printError(constant.addFailed());
notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
});
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class OrionEditorPresenter method onResourceCreated.
private void onResourceCreated(ResourceDelta delta) {
if ((delta.getFlags() & (MOVED_FROM | MOVED_TO)) == 0) {
return;
}
final Resource resource = delta.getResource();
final Path movedFrom = delta.getFromPath();
//file moved directly
if (document.getFile().getLocation().equals(movedFrom)) {
deletedFilesController.add(movedFrom.toString());
document.setFile((File) resource);
input.setFile((File) resource);
updateContent();
} else if (movedFrom.isPrefixOf(document.getFile().getLocation())) {
//directory where file moved
final Path relPath = document.getFile().getLocation().removeFirstSegments(movedFrom.segmentCount());
final Path newPath = delta.getToPath().append(relPath);
appContext.getWorkspaceRoot().getFile(newPath).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
final Path location = document.getFile().getLocation();
deletedFilesController.add(location.toString());
generalEventBus.fireEvent(newFileTrackingStartEvent(file.get().getLocation().toString()));
document.setFile(file.get());
input.setFile(file.get());
updateTabReference(file.get(), location);
updateContent();
}
}
});
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class PlainJavaPagePresenter method onNodeSelected.
@Override
public void onNodeSelected(List<Node> nodes) {
String projectName = dataObject.getName();
List<String> nodeRelativePath = new LinkedList<>();
for (Node node : nodes) {
Path nodeLocation = ((ResourceNode) node).getData().getLocation();
nodeRelativePath.add(nodeLocation.makeRelativeTo(valueOf(projectName)).toString());
}
if (isSourceSelected) {
view.setSourceFolder(convertAttributeValuesToString(nodeRelativePath));
} else {
view.setLibraryFolder(convertAttributeValuesToString(nodeRelativePath));
}
onCoordinatesChanged();
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class EditorPartStackPresenter method onResourceChanged.
@Override
public void onResourceChanged(ResourceChangedEvent event) {
final ResourceDelta delta = event.getDelta();
if (delta.getKind() != REMOVED) {
return;
}
Path resourcePath = delta.getResource().getLocation();
for (EditorPartPresenter editorPart : closedParts) {
Path editorPath = editorPart.getEditorInput().getFile().getLocation();
if (editorPath.equals(resourcePath)) {
closedParts.remove(editorPart);
return;
}
}
}
Aggregations